What is the equivalent of 'CREATE TABLE ... LIKE ..." in SQL Server

Ichorus picture Ichorus · Mar 5, 2009 · Viewed 37.6k times · Source

I am working with SQL Server (I am a SQL Server noob) and trying to alter a table. I want to CREATE TABLE LIKE to safely store data while I drop keys and constraints and all the other rigamorole that SQL Server seems to require when altering on the original table but I have not been able to find a match to that command...

Answer

Fredou picture Fredou · Mar 5, 2009

you want to recreate the same structure?

how about this

 SELECT *
 into test
 FROM myRealTable
 where 0=1

no data will be inserted into the new table