Inserting data into a temporary table

后端 未结 14 1475
情书的邮戳
情书的邮戳 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:47

    My way of Insert in SQL Server. Also I usually check if a temporary table exists.

    IF OBJECT_ID('tempdb..#MyTable') IS NOT NULL DROP Table #MyTable
    
    SELECT b.Val as 'bVals'
      INTO #MyTable
    FROM OtherTable as b
    

提交回复
热议问题