sql批量update數(shù)據(jù) 如何使用sqlserver快速批量更新數(shù)據(jù)?
如何使用sqlserver快速批量更新數(shù)據(jù)?是,例如,when and then語(yǔ)句可以實(shí)現(xiàn)批更新語(yǔ)句update tableuuuown SETcloumnuown=Case ID當(dāng)1然后是“a”當(dāng)
如何使用sqlserver快速批量更新數(shù)據(jù)?
是,例如,when and then語(yǔ)句可以實(shí)現(xiàn)批更新語(yǔ)句
update tableuuuown SET
cloumnuown=Case ID
當(dāng)1然后是“a”
當(dāng)2然后是“B”
當(dāng)3然后是“C”
end
where ID in(1,2,3)
此批更新語(yǔ)句意味著更新clocolumnuown字段,clocolumn if ID=1uown=a,clocolumn if id=2uown=B,clocolumn if id=3uown=C
記住,事實(shí)上,結(jié)束后的where語(yǔ)句不是必需的,但最好帶上它
如果不添加where條件,整個(gè)表的數(shù)據(jù)都會(huì)被更新,不滿足條件的相應(yīng)值會(huì)被設(shè)置為默認(rèn)值值(導(dǎo)致前n-1次執(zhí)行無(wú)效,第n次保留)
如果引入where條件,則不會(huì)發(fā)生這種情況