When you delete rows from a table using the DELETE statment, SQL Server must record the transactions in the transaction log. Deleting a million rows and recording the transactions takes while. The program you use to execute the query has a query or command timeout value that is exceeded so the client throws an error.
If you are deleting all the rows in a table and are a system administrator, database owner or table owner, use TRUNCATE TABLE TableName instead of delete. TRUNCATE TABLE is not logged. If you are not deleting all the rows, then consider deleting the rows in batches of 50k or 100k rows per batch. faq183-3141, "How to Use Batch Size to Speed Mass Updates, Inserts and Deletes," explains a technique for doing this. If you want to get the best answer for your question read faq183-874 and faq183-3179. Terry L. Broadbent - DBA
SQL Server Page:
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.