insert into table2 (zd2)
  select zd1 from table1 where zd1 not in (select zd2 from table2)

解决方案 »

  1.   

    to  CrazyFor(蚂蚁) 
    我觉得好像有问题第一句话insert into table2 (zd2)连values都没有
    而且数据很多,可能是一个循环的insert
      

  2.   

    insert into table2 (column1,column2....)
    select column1,column2.... from table1 where zd1 not in (select zd2 from table2)
      

  3.   

    --是对的,批量插入
    insert into table2 (zd2)
    select zd1 from table1 where zd1 not in (select distinct zd2 from table2)
      

  4.   

    insert table2 (zd2) 
    select zd1 from table1 A 
    where not exists (select * from table2 where zd2 = A.zd1)
      

  5.   

    大家注意,我还有个问题就是
    每条记录都有个主建,从select NewID()得到的全局唯一的32慰的关键字,我怎么加进去呢?
    谢谢~~~
      

  6.   

    其实我这里也是有很多字段的,
    to eastpond(东塘) 能不能把你的那句话写清楚一点
      

  7.   

    select top 3 *,newid() from aaa order by newid()
      

  8.   

    insert table2 (主键列名,zd2) select newid(),zd1 from table1 where zd1 not in (select zd2 from table2)
      

  9.   

    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