【发布时间】:2021-12-11 05:23:18
【问题描述】:
我需要使用循环一次更新 100 万条数据。这就是我所拥有的。
SET Rowcount 1000000
While (1 = 1)
Begin
Begin Transaction
Update as
Set as.productInd = 0
From Product as
Where as.ProductInd IS NULL
If @@RowCount = 0
Begin
Commit Transaction
Break
End
Commit Transaction
End
Set Rowcount 0
【问题讨论】:
-
您的问题是什么?
-
@Larnu 我想检查代码是否正确。
-
您比我们处于更有利的检查位置,@A。另外,Stack Overflow 不是用于代码验证的网站。
-
@Larnu 会及时通知您。谢谢
-
你不想要一个事务,否则你将失去不阻塞和不增长事务日志的好处。你应该只使用
UPDATE TOP (1000000)
标签: sql sql-server loops sql-update