Mssql temporary table creation code ifobject_id (tempdb. dbo. # table) isnotnull & nbsp; droptable # tablegocreatetable # table ([field] type) the code above checks whether a temporary table exists # If it exists, delete it, otherwise, the temporary table is created. * Code for creating a temporary table in mssql for mssqlserver temporary tables
If object_id ('tempdb. dbo. # table') is not null
Drop table # table
Go
Create table # table ([field] type)
// The code above is used to determine whether the temporary table # table exists. If yes, delete the table; otherwise, create the temporary table.
/*
Mssql server temporary table related operations
Create temporary table
Method 1:
Create table # temporary table name (Field 1 constraints,
Field 2 constraints,
.....)
Create table # temporary table name (Field 1 constraints,
Field 2 constraints,
.....)
Method 2:
Select * into # temporary table name from your table;
Select * into # temporary table name from your table;
Note: The above # indicates a local temporary table, and # indicates a global temporary table.
Query temporary tables
Select * from # temporary table name;
Select * from # temporary table name;
Delete temporary table
Drop table # temporary table name;
Drop table # temporary table name;