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

前端 未结 6 1842
刺人心
刺人心 2020-12-25 11:08

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

query1 :-

select * into table1 from tabl         


        
6条回答
  •  清酒与你
    2020-12-25 11:53

    select * into table1 from table2 where 1=1
    

    The query above requires that the table DOES NOT exist. You do not need to specify columns as all columns are created as they are retrieved from the source table.

    insert into table1 select * from table2 
    

    For the above query, you need an EXISTING table1. The columns in both tables should also be in exactly the same order, otherwise you need to provide a column list for both tables.

提交回复
热议问题