表A有字段 id(identity1,1) 序列号  数量 种类 等表B有字段 id(identity1,1) 序列号 型号 数量 种类 来源 等表A中的数据有一部分在表B中也有,还有一部分表B中没有需要从表A中导过来(主要导的是序列号,数量,种类,型号默认为1)求语句 
或者小程序

解决方案 »

  1.   


    insert 表B ( 序列号 ,数量 ,种类,  型号) 
    select   序列号, 数量, 种类,1 from 表A 
    where not exists(select 1 from 表B where 表B.序列号= 表A.序列号 and   表B.种类=表A.种类)
      

  2.   

    insert into B select identity1, qty, type, 1 from A
                  except 
                  select identity1, qty, type, 1 from B            
      

  3.   


    insert into B (序列号,数量 ,种类,型号)
    select A.序列号,A.数量,A.种类,1 as[型号] from A
    where not exists (select 1 from B where A.序列号=B.序列号)