Best way to create a temp table with same columns and type as a permanent table

前端 未结 6 592
长发绾君心
长发绾君心 2021-01-30 04:03

I need to create a temp table with same columns and type as a permanent table. What is the best way to do it? (The Permanent table has over 100 columns)

i.e.

Usu

6条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 04:38

    Sortest one...

    select top 0 * into #temptable from mytable
    

    Note : This creates an empty copy of temp, But it doesn't create a primary key

提交回复
热议问题