If you don't require the transaction log for recovery purposes then you need to change the recovery model that the database is using to SIMPLE so this doesn't happen again. You can do this by executing
ALTER DATABASE databasename SET RECOVERY SIMPLEDBCC SHRINKFILE should then be able to reduce the log file to a reasonable size. Alternatively you can clear the transaction log of committed transactions by executing
BACKUP LOG databasename WITH TRUNCATE_ONLYDBCC SHRINKFILE should now also be more effective, however if you don't change the recovery model to SIMPLE the log file will just fill up over time again. Search on "Selecting a Recovery Model" in SQL Server Books online for more information.
For More Information
- Dozens more answers to tough SQL Server questions from Tony Bain are available here.
- The Best Microsoft SQL Server Web Links: tips, tutorials, scripts, and more.
- The Best SQL Web Links
- 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, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
This was first published in June 2002