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

前端 未结 6 1832
刺人心
刺人心 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:45

    a) select * into table1 from table2 where 1=1 -If table1 and table2 already exist, you will get below error when you execute the query. "Msg 2714, Level 16, State 6, Line 1 There is already an object named 'table1' in the database"

    b) insert into table1 select * from table2 -If table1 is duplicate of table2 ,then this query consider common insert statement Exp: select * into table1 from table2 where 1=0 However bare in mind, you will accumulate duplicate data each time you execute the query.

提交回复
热议问题