Copy table schema to new a table
In SQL Server,
SELECT INTO is used to copy data from an existing table/s into a new one.
However by adding a
WHERE clause which will always return false, this will prevent any data from being copied, and therefore create an empty copy of the table schema into a new table.
For example if we have a table, “TableA”, the schema of this table can be copied into a new table, “TableB”, by executing the following:
SELECT * INTO TableB FROM TableA WHERE 1=0