---do not use set rowcount.
--Use top n
WHILE (1=1)
BEGIN
BEGIN TRANSACTION
UPDATE r
SET col1= col2
from Table1 r
where r.col3 in (select top 10000 col3 from Table1 where col1 is null)
-- Update 10000 nonupdated rows
IF @@ROWCOUNT = 0
BEGIN
COMMIT TRANSACTION
BREAK
END
COMMIT TRANSACTION
END
This blog is created to add all the information and experiences that I have learnt while working on MS sql server as a DBA. The blog is also updated frequently with the real world problem that I encounter hands on at work and the resolutions to resolve them. I hope this blog will be of some use to you and you will revisit. Thank you for stopping by and you are welcome to leave comments.
Showing posts with label update. Show all posts
Showing posts with label update. Show all posts
Friday, January 2, 2015
Subscribe to:
Posts (Atom)