Script to update table in patches

  • Hi All,

    I have a table that takes more time to update large number of records(millions of records). Is there any way(script) that updates the same in batches(say 500 at a time), by which it takes less time and also performance is faster.

    Thanks in advance.

    Priya

    Regards
    Priya

  • yes, but you have to be able to identify what has not been changed.

    it most likely will NOT be faster, but should avoid locking the entire table for the updates

    something like this:

    SET ROWCOUNT 500

    WHILE 1=1

    BEGIN

    UPDATE dbo.myTable

    SET SOMEVALUE = ???

    WHERE MyField = My Condition

    IF @@ROWCOUNT = 0

    BREAK

    END

    SET ROWCOUNT 0

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply