The task is to have a table, you need to create its copy ... or an empty table with the same structure ...
Previously, I usually used DTS for these purposes, since the need for copying was rarely encountered and usually referred to a single table. It didn't break me to launch Enterprise Manager / Management Studio.
Today it became necessary to copy the tables ... many, different and without going beyond the framework of the program being developed ... i.e. DTS does not offer, and in general it is desirable to do only T-SQL'em.
')
“Oh, Momma, now you should get the name of the source table to tear off the create statement, don't forget about the constraints and foreign keys ... :(” - I thought.
and then, lo and behold! there is a way to copy the structure of the table into one line:
select * into [destinationTable] from [sourceTable] where 0 = 1
If the table [destinationTable] does not exist, then it will be created! With the same columns, indexes and other. True, foreign keys will be lost, but now dancing with a tambourine will now have much less: D
ZY: maybe it's a dupe, but I didn't know about such behavior select ..into: ")