How to create a empty temporary table from another tables schema?
10,588
Solution 1
select * into x_temp from tbl where 1 = 0
Solution 2
This works in most DBs:
create table blah as
select * from foo where 1=0
Note that this will not copy PKs, indexes, etc.
Solution 3
select top 0 * into temp_table from table
This is what I typically use, but I like Michael B's method too.
Comments
-
Keith Nicholas about 2 years
Is there an idiomatic way of doing this?