根据两个表关联的id,用一个表的数据更新另一个表的数据. 写一条Sql语句

解决方案 »

  1.   

    update a set
      field = b.field
    from a
    join b on a.id=b.id
      

  2.   

    --try
    update tb1
    set tb1.name = tb2.name
    from tb1 inner join tb2 on tb1.id = tb2.id
      

  3.   


    --更新表1的COL字段.
    update A set A.col = B.col from 表1 A,表2 B where A.id = B.id
      

  4.   

    写一个触发器
    create trigger tri_update
    on Atable after update
    as
    update Btable 
    set Btable.col=inserted.col
    from inserted
    where  Btable.primarycol = inserted.primarycol 
           
      

  5.   

    呀看错问题了,一条sql语句的话上面的都可以