How to empty a SQL Server database transaction log file

I have 1 GB databases that grow several GB log files.

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 :

backup log [dbname] with truncate_only
go
DBCC SHRINKDATABASE ([dbname], 10, TRUNCATEONLY)
go

Warning : Clearing the transaction log with TRUNCATE_ONLY will break your backup chain needed for FULL recovery. A FULL database backup should be executes right after truncating the logs

extradrmtech

Since 20 years I work on Database Architecture and data migration protocols. I am also a consultant in Web content management solutions. I am an experienced web-developer with over 10 years developing PHP/MySQL, C#, VB.Net applications ranging from simple web sites to extensive web-based business applications. When not writing code, I like to dance salsa and swing and have fun with my little family.

You may also like...