日期:2014-05-18 浏览次数:20500 次
update B set B.XVersion=A.Version where exists(select 1 from A where A.columN1=B.column4 and A.Column2=B.Column5 and A.Column3=B.Column6 and A.Version!=B.Xversion)
------解决方案--------------------
update A set A.version=B.xversion from A join B on A.columN1=B.column4 and A.Column2=B.Column5 and A.Column3=B.Column6 where B.xversion>A.version
------解决方案--------------------
update a
set a.version=b.xversion from a left join b on
A.columN1=B.column4 and A.Column2=B.Column5 and A.Column3=B.Column6
where B.xversion>A.version
------解决方案--------------------
UPDATE a SET version=ISNULL(xversion,version) FROM tA a LEFT JOION tb b ON a.c1=b.c4 AND a.c2=b.c5 AND a.c3=b.c6 AND xversion>version
------解决方案--------------------
应该用内连,找不到就不更新.我用左连多操作了一些记录.虽然结果一样,但是多操作了记录.
就像2,3楼写的那样就可以了.