update  test.dbo.[09zb]  set [08年序号]=test.dbo.[08zb].序号 where 
EXISTs(select * from test.dbo.[08zb] A where  A.生产企业=test.dbo.[09zb].生产企业 and A.包装数量=test.dbo.[09zb].包装数量)
08zb表中有个序号,我想把相应的生产企业、包装数量相等的记录的“序号”字段 填入 09zb表中的"[08年序号]" 字段但set后写错了,望指点。

解决方案 »

  1.   

    update a
    set a.[08年序号]=b.序号 
    from test.dbo.[09zb] a,test.dbo.[08zb] b
    where b.生产企业=a.生产企业 and b.包装数量=a.包装数量
      

  2.   

    update a set 
    A.[08年序号]=B.序号 
    from test.dbo.[09zb] A
    JOIN test.dbo.[08zb] B
    ON B.生产企业=A.生产企业 and A.包装数量=B.包装数量
      

  3.   

    update
     a
    set
     a.[08年序号]=b.序号 
    from
     test.dbo.[09zb] a,test.dbo.[08zb] b
    where
     b.生产企业=a.生产企业 and b.包装数量=a.包装数量