Monday, February 16, 2015

SELECT INTO Query in SQL Server.

In SQL Server we can create a Table using another Table.

Here we can use SELECT INTO Statement.

If we create a new Table with all the Fields and Data of another Table. Then we use...

SELECT * INTO <new_table>
FROM <existing_table>

Or we can use WHERE Clause...

SELECT * INTO <new_table>
FROM <existing_table>
WHERE 1 = 1

Now if we create the Table only the Fields of another Table. Then we use...

SELECT * INTO <new_table>
FROM <existing_table>
WHERE 1 = 0

No comments:

Post a Comment