1. The syntax to create a LOCAL TEMPORARY TABLE in SQL Server is:
CREATE TABLE #table_name
(
column1 datatype [ NULL | NOT NULL ],
column2 datatype [ NULL | NOT NULL ],
...
);
Not: The name of LOCAL TEMPORARY TABLES are prefixed with the # character
(Ex. #Customer)
For Example
CREATE TABLE #Customer
(
cus_id INT PRIMARY KEY,
first_name VARCHAR(20) NULL,
last_name VARCHAR(20) NOT NULL
);
Note: The #Customer table is stored in tempdb and SQL Server will automatically delete this table when the SQL Server session no longer requires it.
No comments:
Post a Comment