Divide big delete into several small ones

  • I'm sure there are better descriptions of transaction handling, but I hope someone else known the reference. I was fortunate to have a couple of days to test different scenarios and built a template based on the results. Even at that - we have very few routines that need to break the handling into loops of BEGIN and COMMIT. Those tend to be archive, purge and mass-move type of routines.

    Guarddata-

  • One point to add to this is that you MUST set your rowcount to 0 after the loop! Not doing so will limit all your following queries to the same 1000 records and may really cuase problems. 🙂

    Also this can be a way of keeping your log file from growing too large as you can truncate the log inside the loop if needed as well.

    Gary Johnson

    Microsoft Natural Language Group

    DBA, Sr. DB Engineer




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

  • Another point to note is that you can stop this type of query at any point with out losing work already done. So if youe query locks up tables and holds up other users you can easily just stop it. and continue later.

Viewing 3 posts - 16 through 17 (of 17 total)

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