Sqlserver实现多表关联更新

A表 TYS_XM_RELATION2019 

B表 TYS_XMYS2019(部分字段)

目标 :将B表的ysxmh用A表的newysxmh代替。代替条件A表的oidysxmh = B表的ysxmh

update B set B.ysxmh = A.newysxmh from A,B  where A.oldysxmh = B.ysxmh;

( UPDATE TYS_XMYS2019 SET TYS_XMYS2019.YSXMH=TYS_XM_RELATION2019.newYsxmh  FROM  TYS_XMYS2019, TYS_XM_RELATION2019
  WHERE TYS_XMYS2019.YSXMH=TYS_XM_RELATION2019.oldYsxmh AND TYS_XMYS2019.HBDWBH=TYS_XM_RELATION2019.HBDWBH AND TYS_XMYS2019.HBDWBH='3501' )

 

posted on 2019-02-26 14:45  techno-geek  阅读(7140)  评论(0编辑  收藏  举报