Monday, June 25, 2012

Quickly Duplicate an Existing Table [SQL Server]


This is a tip for quickly duplicating an existing table.
Select * Into new_table_name From existing_table_name
While this is another tip for quickly creating a table with the same column name of an existing table.
Select * Into new_table_name From existing_table_name Where 1 = 2
Notice the where condition.  You could actually change it to any condition that returned false (e.g 1=0).  The select statement will select nothing.


No comments:

Post a Comment