將查詢(xún)結(jié)果插入到另一個(gè)表的三種情況
1.要插入的目標(biāo)表不存在
select *? into 目標(biāo)表 From 表 where。。。
2.要插入的目標(biāo)表已存在
insert into 目標(biāo)表 select * from 表 where 條件
3.跨數(shù)據(jù)庫(kù)的操作:A庫(kù)到b庫(kù)
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 ;