views:

133

answers:

3

Is there an idiomatic way of doing this?

A: 

Here is a script that claims to work on SQL 2005.

Dave Swersky
+1  A: 

This works in most DBs:

create table blah as
select * from foo where 1=0

Note that this will not copy and PKs, indexes, etc.

Donnie
This indirection does not work in SQL Server.
Aaron Bertrand
+6  A: 
select * into x_temp from tbl where 1 = 0
Michael Buen