Deleting is generally slow because deletes are logged transactions. You can speed things up by locking the table before starting the delete. Add statements like the following before the delete statement.
Begin Transaction
--Lock table and hold lock to end of transaction
Select * From Table (with tablockx, holdlock)
Where 1=2
Delete...
Commit Transaction
Usually, it is faster to delete in multiple smaller batches and commit the transaction after each batch. This prevents the LOG from growing very large trying to hold all of the uncommitted deletes. Add Set Rowcount to the script to limit the number of records deleted in each transaction.
--Limit number of deletes to 10000
Set Rowcount 10000
<Delete script>
Set Rowcount 0 Terry L. Broadbent FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.