(
cot1 kieudulieu [ NULL | NOT NULL ],
cot2 kieudulieu [ NULL | NOT NULL ],
…
);
ten_bang
The name of the local temp table wants to be created, starting with the # character.
cot1, cot2
The column you want to create in the table. Each column has 1 data type, must be specified to contain NULL or NOT NULL values, otherwise default is NULL.
Data types in SQL Server
Note
The local temp table LOCAL TEMPORARY TABLE has a prefix of # (for example, need #nhanvien).
For example
CREATE TABLE #nhanvien
( id_nhanvien INT PRIMARY KEY,
ho (VARCHAR(50) NOT NULL,
ten (VARCHAR(50),
luong MONEY,
);
For example, the CREATE TABLE command will create a local temporary table named #nhanvien with 4 columns:
The # table is stored in tempdb and SQL Server will be automatically deleted when the SQL Server session is no longer needed.
Previous post: GLOBAL TEMPORARY TABLE in SQL Server
The following article: Foreign Key foreign key in SQL Server