Is it possible to handle a transaction log full error in T-SQL ? I have one T-SQL for DBCC DBREINDEX which is scheduled in the background once weekly. In this script I identify tables with scan density < 90 % and do DBCC DBREINDEX for all those tables in a loop. Even though the transaction log backup is scheduled in 10-minute frequencies, sometimes the transaction log becomes full and the process terminates. Is there is any possibility to handle the 9002 error in the same script in order to put a pause for 30 or 35 minutes (by the time transaction log backup will happen) and continue the process with the remaining tables? If possible, checking the transaction log used percentage will also be a help to me.
We are using MS SQL Server 2000 with SAP R/3 4.6C. Our database size is 219 GB and transaction log size is 19 GB. Further increase of the size of the transaction log is a constraint now. Moreover, in the normal run, even though we back up the transaction log at a two-hour duration, the percentage of use is very nominal.
I would suggest moving to using indexdefrag which will have a lower impact on the size of your transaction log files.
For More Information
- Dozens more answers to tough SQL Server questions from Michael Hotek are available here.
- The Best Microsoft SQL Server Web Links: tips, tutorials, scripts, and more.
- Have a SQL Server tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical SQL Server questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, SQL Server, DB2, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
This was first published in June 2004