SQL Server 'select * into' versus 'insert into ..select *

Sujit Prabhakaran picture Sujit Prabhakaran · Dec 19, 2011 · Viewed 88.9k times · Source

Say table1 and table2 already exist, is there any difference between these queries

query1 :-

select * into table1 from table2 where 1=1

query2: -

insert into table1 select * from table2

Answer

aF. picture aF. · Dec 19, 2011

The select * into table1 from table2 where 1=1 creates table1 and inserts the values of table2 in them. So, if the table is already created that statement would give an error.

The insert into table1 select * from table2 only inserts the values of table2 in table1.