The difference between select into and insert into select the

Because of the recent batch entry uses a database, from the Internet to find information both better way to know for the future easier to find, especially on this record, hoping to allow other colleagues!
Select and insert into select two kinds INTO table replication statement
select iNTO destTbl from srcTbl *

iNSERT iNTO destTbl (FLD1, FLD2) SELECT FLD1, srcTbl. 5 from

the above two data are inserted into the srcTbl destTbl, but there are two differences.

The first sentence (select into from) requires that the target table (destTbl) does not exist, because it will be created automatically upon insertion.

The second sentence (insert into select from) requires that the target table (destTbl) exists, because the destination table already exists, we inserted in addition to the source table (srcTbl) fields, constants may also be inserted as in Example: 5.
Further, deleting the table entry process was repeated as follows:
SELECT DISTINCT * INTO table_name from #table_name
Delete from table_name
SELECT * from #table_name INTO table_name
drop Table #table_name

Reproduced in: https: //www.cnblogs.com/yangjie5188/archive/2008/04/23/1167061.html

Guess you like

Origin blog.csdn.net/weixin_34306676/article/details/93499947