insert table2 (主键列名,zd2) select newid(),zd1 from table1 where zd1 not in (select zd2 from table2)
create proc p_copy as insert table2 (主键列名,zd2) select newid(),zd1 from table1 where zd1 not in (select zd2 from table2) /*如果插入全部数据,用这个: insert table2 (主键列名,其他列) select newid(),其他列 from table1 where zd1 not in (select zd2 from table2) */ go
我觉得好像有问题第一句话insert into table2 (zd2)连values都没有
而且数据很多,可能是一个循环的insert
select column1,column2.... from table1 where zd1 not in (select zd2 from table2)
insert into table2 (zd2)
select zd1 from table1 where zd1 not in (select distinct zd2 from table2)
select zd1 from table1 A
where not exists (select * from table2 where zd2 = A.zd1)
每条记录都有个主建,从select NewID()得到的全局唯一的32慰的关键字,我怎么加进去呢?
谢谢~~~
to eastpond(东塘) 能不能把你的那句话写清楚一点
as
insert table2 (主键列名,zd2) select newid(),zd1 from table1 where zd1 not in (select zd2 from table2)
/*如果插入全部数据,用这个:
insert table2 (主键列名,其他列) select newid(),其他列 from table1 where zd1 not in (select zd2 from table2)
*/
go