在A表中插入在B表中的值例:
A表
id name notes
1  2
2  2
1  3
2  3B表
id name notes
1  2
3  1
2  4
2  3
结果 
id name notes
1  2
2  2
1  3
2  3
3  1
2  4

解决方案 »

  1.   

    Insert into b
    select * 
    from a 
    where exists (select 1 from b where a.id<>b.id and a.name<>b.name)
      

  2.   

    insert #temp2_wastebookselect a.shopid,a.deptid,a.goodsid,convert(dec(10,2),'0.00'),convert(dec(10,2),'0.00') from #temp1_SaleCost a,#temp2_wastebook b
    where a.shopid=b.shopid and a.deptid=b.deptid and a.goodsid=b.goodsid
    你这样给我改一下吧!给上面插入除过下面语句中的数据
      

  3.   

    INSERT  #temp2_wastebook
             SELECT  a.shopid ,
                     a.deptid ,
                     a.goodsid ,
                     CONVERT(dec(10, 2), '0.00') ,
                     CONVERT(dec(10, 2), '0.00')
             FROM    #temp1_SaleCost a
             WHERE   NOT EXISTS ( SELECT 1
                                  FROM   #temp2_wastebook b
                                  WHERE  a.shopid = b.shopid
                                         AND a.deptid = b.deptid
                                         AND a.goodsid = b.goodsid )