The reason you put the
WHERE 1=2 clause in that
SELECT INTO query is to create a field-copy of the existing table with no data.
If you did this:
Table2 would be an exact duplicate of
Table1, including the data rows. But if you don't want the data contained in
Table1, and you just want the table structure, you put a
WHERE clause to filter out all of the data.
SELECT INTO Reference quote:
SELECT…INTO creates a new table in the default filegroup and inserts the resulting rows from the query into it.
WHERE clause has no resulting rows, none will be inserted into the new table: Therefore, you end up with the duplicate schema of the original table with no data (which would be the desired result in this case).
The same effect can be achieved with
TOP (0), for example:
select top (0) *
SELECT INTO will not duplicate the source table's indexes, constraints, triggers, or partition schema.