Tuesday, May 11, 2010

How to empty a SQL Server database transaction log file

I have 1GB databases that grow several GB log files.  How do you safely clear those logs?  Well, probably the best practice includes backing them up.  That was overkill for me, and sifting through all the documentation and forums (eventually) led me to this simple pair of statements that do the trick immediately:

view plaincopy to clipboardprint?

backup log [dbname] with truncate_only  

DBCC SHRINKDATABASE ([dbname], 10, TRUNCATEONLY)  

No comments:

Post a Comment