SQL Update committed after 10000 transactions

  • I have a update script

    update membership

    set effdat=enrolldat

    There problem is that I need to update 60 million row of data.

    How can I do to make the transcation commit every 10000 row.

    Thanks,

    Qjlee

  • would need the actual talbe def and some sample date. Nonetheesee there are several ways. If you're not concerned w using transactions then u can use and update statement join the table being ubdated join to the same table w/ a select top 10000 in there.

    If you must use transactions then u can either loop though the set using a cursor or what i call is a manual cursor which is loading the recs into a temp table and loping through them w/ a rocessed flag or an id of sorts to keep you place. Again w/o table defs and data your not going to get very far on this site.

  • hard to say with out sample data and no table structure

    a very simple way is

    top 10000 control with a WHERE effdat <> enrolldat

    If you give me some more info I can write the statement

    I should be able to do this without using cursor, temp tables , or flags

    Scott

    Scott
    I am a Senior Data Analyst/DBA
    I work with MS SQL, Oracle & several ETL Tools

    @thewolf66[/url]

  • QQ-485619 (11/18/2010)


    How can I do to make the transcation commit every 10000 row.

    There is a complete explanation and script in the following SSC article by Lynn Pettis:

    http://qa.sqlservercentral.com/articles/67898/

    The article covers deleting a large number of records efficiently, but the principle is exactly the same for update.

  • Paul White NZ (11/19/2010)


    QQ-485619 (11/18/2010)


    How can I do to make the transcation commit every 10000 row.

    There is a complete explanation and script in the following SSC article by Lynn Pettis:

    http://qa.sqlservercentral.com/articles/67898/

    The article covers deleting a large number of records efficiently, but the principle is exactly the same for update.

    This is the method I us I have a SPROC that I just past the statement and tran ct one thing you need to remember that the where clause must not create a loop something like 1=1 will only update the top 10000 records over and over

    Scott
    I am a Senior Data Analyst/DBA
    I work with MS SQL, Oracle & several ETL Tools

    @thewolf66[/url]

  • shump66 (11/19/2010)


    This is the method I us I have a SPROC that I just past the statement and tran ct one thing you need to remember that the where clause must not create a loop something like 1=1 will only update the top 10000 records over and over

    Yes, I thought that was what you meant - it reminded me of Lynn's article.

Viewing 6 posts - 1 through 5 (of 5 total)

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