Working environment is SQL Server 2000. I have a table with no indexes, no PK… Total number of rows is 600,000.
How can I update a column from row 0 -> 100,000 with a value then from 100,001 -> 200,000 with another, and so on?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
set all values to null, then SET ROWCOUNT 100000. Then do successive updates ( each will affect 100000 rows) with different values where that column IS NULL. @@rowcount will be the number of rows affected after each update, so stop when it is less than 100000.
For @Shannon’s comment, the ROWCOUNT will not be honored for update/delete/insert statements in the next version of SQL Server (post-SQL Server 2008), but it will work fine for SQL Server 2000. The recommended change is to use the TOP clause, but I don’t think that is supported for updates until SQL Server 2005.
I think you could sue a cursor if you wanted…