xxxxxxxxxx
-- CREATE TEMP TABLE
Create Table #MyTempTable (
EmployeeID int
);
-- DROP TEMP TABLE
IF OBJECT_ID('tempdb..#MyTempTable') IS NOT NULL DROP TABLE #MyTempTable
xxxxxxxxxx
-- Create temp table
CREATE TEMP TABLE temp_table (
id INT,
name VARCHAR(30)
);
-- Query results to store in the temporary table on the fly
CREATE TEMP TABLE temp_table AS
SELECT column1, column2
FROM table_name;
-- Insert values in temporary table from another table
INSERT INTO temp_table
SELECT column1, column2
FROM another_table
-- Delete temporary table
DROP TABLE IF EXISTS temp_table;
xxxxxxxxxx
IF Object_ID('tempdb..#Tablename') IS NOT NULL DROP TABLE #Tablename
Select
*
into
#Tablename
FROM
SampleTable
xxxxxxxxxx
-- CREATE TEMP TABLE
Create Table #MyTempTable (
EmployeeID int
);
xxxxxxxxxx
If(OBJECT_ID('tempdb..#temp') Is Not Null)
Begin
Drop Table #Temp
End
xxxxxxxxxx
declare @table table (id int)
create table #table (id int)
create table ##table (id int)
select * into #table from xyz
xxxxxxxxxx
CREATE TABLE #name_of_temp_table (
column_1 datatype,
column_2 datatype,
column_3 datatype,
.
.
column_n datatype
)