Skip to content
Advertisement

Inserting data into a temporary table

After having created a temporary table and declaring the data types like so;

CREATE TABLE #TempTable(
ID int,
Date datetime,
Name char(20))

How do I then insert the relevant data which is already held on a physical table within the database?

Advertisement

Answer

INSERT INTO #TempTable (ID, Date, Name) 
SELECT id, date, name 
FROM physical_table
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement