Inserting data into a temporary table

后端 未结 14 1498
情书的邮戳
情书的邮戳 2020-12-22 22:28

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

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

H

14条回答
  •  悲哀的现实
    2020-12-22 22:39

    All the above mentioned answers will almost fullfill the purpose. However, You need to drop the temp table after all the operation on it. You can follow-

    INSERT INTO #TempTable (ID, Date, Name) SELECT id, date, name FROM physical_table;

    IF OBJECT_ID('tempdb.dbo.#TempTable') IS NOT NULL DROP TABLE #TempTable;

提交回复
热议问题