Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timeout expired when deleting a million record table

Status
Not open for further replies.

gorack

Programmer
Mar 27, 2003
10
CA
why ?
 
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:
 
Thanx! I forgot the TRUNCATE TABLE command hehheh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top