Sunday, February 19, 2012

Copy the table structure

Hi,
In SQL Server, Is there any DDL available to copy a table structure alone and not the data,
I believe 'SELECT * into new_table from table1' will copy both structure and data as well.
Please advice,
Thanks,
MiraJYou can use SELECT...INTO to create an identical table definition (different table name) with no data by having a FALSE condition in the WHERE clause.

SELECT * INTO new_table FROM table1 WHERE 1 = 0|||Understand though that Indexes and constraints do not get copied over...

No comments:

Post a Comment