现在有两张表A,B,各有两个字段 bbh,bbhmc
1.A中的bbh不是主键
2.B中的bbh是主键
现在表A在那个bbhmc与B表中的字段不一致,想Update改为相同,求语句?谢谢

解决方案 »

  1.   

    update A set bbhmc=B.bbhmc
    from A,B
    where A.bbh=B.bbh
      

  2.   

    update a 
    set bbhmc = b.bbhmc
    from b
    where a.bbh=b.bbh
      

  3.   

    select id identity(int),* into #t from a
    update a set bbhmc=b.bbhmc from #t a,b where a.id=b.bhh
      

  4.   

    update A 
    set bbhmc=B.bbhmc
    from A,B
    where A.bbh=B.bbh
      

  5.   

    select id=identity(int),* into #t1 from a
    select id=identity(int),* into #t2 from b
    update a set bbhmc=b.bbhmc from #t1 a,# t2b where a.id=b.id
      

  6.   


    update a
    set bbhmc=b.bbhmc
    from a,b
    where a.bbh=b.bbh
      

  7.   

    UPDATE A SET BBHMC=B.BBHMC FROM B WHERE A.BBH=B.BBH
      

  8.   

    select id=identity(int),* into #t1 from a
    select id=identity(int),* into #t2 from b
    update a set bbhmc=b.bbhmc from #t1 a,# t2 b where a.id=b.id
      

  9.   

    update

    set 
    bbhmc=b.bbhmc
    from 
    a,b
    where 
    a.bbh=b.bbh