日期:2014-05-17  浏览次数:20515 次

批量update
有一张表Inventory (cInvCode ,iSafeNum )
有另一张表bb(cInvCode ,iSafeNum )

现在我要把表bb里面的iSafeNum 值,批量更新到表Inventory ,条件是
Inventory.cInvCode=bb.cInvCode

谢谢

------解决方案--------------------
SQL code

update a
set a.iSafeNum = b.iSafeNum
from bb a join Inventory b on a.cInvCode = b.cInvCode

------解决方案--------------------
update b
set b.iSafeNum = a.iSafeNum
from bb a join Inventory b on a.cInvCode = b.cInvCode


------解决方案--------------------
SQL code
update b
set b.iSafeNum = a.iSafeNum
from bb a join Inventory b on a.cInvCode = b.cInvCode

------解决方案--------------------
SQL code

update Inventory set iSafeNum=bb.iSafeNum 
from Inventory,bb 
where Inventory.cInvCode=bb.cInvCode