Insert插入
2018-03-02 本文已影响0人
Aaether
将查询结果插入到另一个表的三种情况
1.要插入的目标表不存在
select * into 目标表 From 表 where。。。
2.要插入的目标表已存在
insert into 目标表 select * from 表 where 条件
3.跨数据库的操作:A库到b库
select * into B.table from A.table where
eg:
INSERT INTO NEGH.dbo.test1(FLOW_ID) select GSMD.dbo.BT_AREA.FLOW_ID from GSMD.dbo.BT_AREA ;
select GSMD.dbo.BT_AREA.FLOW_ID into NEGH.dbo.test1 from GSMD.dbo.BT_AREA ;