essence of a stored procedure is to encapsulate a piece of code.Created: Create proc procname@param1 int, @param2 int outputAsSet @param2 [email protected] * @param1Parameter default: Stored procedure only the last parameter can have a default value.19. Index[Focus Index]:[non-focused index]:Create INDEX IndexName on TableName (fieldName)20. TriggersAn operation is performed automatically when a
--The project needs to use the Merg grammar, so went online to check the data, found that it is a multi-table query, the problem is that I only have a table, so I am puzzled, and then I brainwave, it's done!--Table name: T_login (Login table)--field: F_username (username), f_status (login status 0 = logged in)--Executi
The syntax differences between SQL Server and access are listed below to facilitate the query when replacing the program database.
Date separator SymbolAccess: Pound sterling character (#)SQL Server: apostrophe (')
Boolean ConstantsAccess:true, False;on, Off;yes, No; integ
UNIQUE constraint in the "id_p" column when the "Persons" table is created:Mysql:CREATE TABLE Persons (id_p int not null,lastname varchar (255) not null,firstname varchar (255), Address varchar (255), City VA Rchar (255), UNIQUE (Id_P) )SQL Server/oracle/ms Access:UNIQUE, LastName varchar (255) not null,firstname varc
transaction, functionally, that is a reversal of the previous transaction.The commit TRAN syntax is as follows:commit tran[saction][
1
Rollback TranRollback is a transaction rollback, and anything that happens from the associated begin statement is forgotten, that is, all the operations that the transaction contains are undone. In addition to allowing savepoint, the syntax of rollback looks
above code, we can see that this table has the characteristics of the general table--there is a primary key, and the primary key is also a clustered index. As mentioned earlier, a partitioned table is a partition condition for a field, so you cannot create a clustered index other than this field. Therefore, to convert
is no longer in use
Exec sp_dropserver 'itsv', 'droplogins'
-- Connect to remote/LAN data (openrowset/openquery/opendatasource)
14. openrowset
-- Query example
Select * from openrowset ('sqlodb', 'SQL Server name'; 'username'; 'Password', database name. dbo. Table name)
-- Generate a local table
Select * into
SQL Server stored procedure syntax:
Create PROC [edure] procedure_name [; number]
[{@parameter data_type}
[varying] [= default] [OUTPUT]
Introduction of parameters
1, procedure_name
The name of the new stored procedure. Procedure names must conform to the rules for identifiers and must be unique to t
The table-valued parameter is a new parameter type in SQL Server 2008. Table-valued parameters are declared using a user-defined table type. With table-valued parameters, you can send multiple rows of data to a Transact-
drop table [a] go create table [a] ([ID] int) insert [a] select 1 union allselect 1 union allselect 2 union allselect 3 union allselect null select * from a/* (5 rows affected) ID-----------1123NULL (5 rows affected) */--> test data: [B] if object_id ('[B]') is not null drop table [B] go
SQL connections can be divided into internal, external, and cross-joins.1. Internal connection: Inner Join the query operation lists the data rows that match the join criteria, which uses comparison operators to compare the column values of the concatenated columns.1.1 SELECT * from Table1 as a, Table2 as B where a.id= b.id1.2 SELECT * FROM Table1 as a inner joins Table2 as B on a.id = b.ID
External connection2.1 Left OUTER join (simply put, lef
brought by ParameterizationThis is how to deal with @p_CustomerId this parameter, directly @p_customerid in the form of a string in the SQL statement,In this case, it is equivalent to the ad hoc query, not by the parameterized way to CustomerID This query condition field assignmentIF (@p_CustomerId is not NULL)SET @sqlcommand = CONCAT (@sqlcommand, ' and customerid= ', @p_CustomerId)So that when you execute the stored procedure again,When brought int
transaction is to issue a new transaction, functionally, that is a reversal of the previous transaction. The commit TRAN syntax is as follows: commit tran[saction][Rollback TranRollback is a transaction rollback, and anything that happens from the associated begin statement is forgotten, that is, all the operations that the transaction contains are undone. In addition to allowing savepoint, the syntax of r
--Data manipulation
SELECT-Retrieve rows and columns of data from a database table
INSERT-Add new data rows to a database table
Delete-Deletes rows of data from a database table
Update--updating data in a database table
--Data definition
CREATE
session is disconnected or the temporary table is deleted (drop).But when the new session invocation also contains the code that creates the temporary table, SQL Server internally reuses the temporary table created at the time of the previous session without having to defin
connections with different structuresWhen the two tables are many-to-many relationships, we need to create an intermediate table Student_score, with at least two tables of primary keys in the intermediate table.SQL statements: Select S.name,c.cname from Student_score as SC left joins student as S on S.SNO=SC. Sno left joins score as C on C.CNO=SC. CnoSelect from student left joins score on student. Num
external environment, the result set cannot be returned by the Select, Update,delete, database table;3. You must return a scalar value or a table variable custom function is generally used in a high degree of reuse, simple function, a strong fight against the place. Second, the stored procedure1. Cannot return table variable2less restrictive, can perform operati
Tags: LSE WOT form ROP ENC war composite case pathIn the previous chapters we talked about: if the data for a table is a union of multiple tables, and there is a merge of columns and columns to form a new column, the view is the best scenario.Below I share two real SQL statement cases Usewot_inventoryGOIF EXISTS(SELECT 1 fromSys.viewsWHEREName= 'Invoicesearchlistview') DROP VIEWInvoicesearchlistview;GOC
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.