这篇文章主要讲解了“SQLServer怎么实现批量更新”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“SQLServer怎么实现批量更新”吧!
1、直接用top N来实现批量更新
update top(1000) table1 set SysNo = 0 ,UpdateTime = getdate() where Status not in (-1,-2,-3,-4,-5,4) and StockStatus <> 2 and isnull(CaiSysNo,0) = 0 and SysNo = 1;
2、用中间表实现批量更新
select SysNo into table1_temp01
FROM table1
WHERE EXISTS (SELECT 1 FROM table1_History..table1_History a WHERE a.SysNo=table1.SysNo);
UPDATE TOP(5000)
from table1
where SysNo in
(select SysNo from table1_temp01);
感谢各位的阅读,以上就是“SQLServer怎么实现批量更新”的内容了,经过本文的学习后,相信大家对SQLServer怎么实现批量更新这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!