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:

backup log [dbname] with truncate_only

Update: Mathias added a comment that deserves calling out:

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. More info.

25 thoughts on “How to empty a SQL Server database transaction log file”
  1. with 400 users and a report dept that suddenly started “trying things out”, I had a log file almost as large as the VM I was running in.

    Thanks for your blog entry ! You’re a lifesaver !

  2. thanks a Lot Man, I am really happy, trying to email the database since long, but fail due to file size.

    Muhammad Sharjeel Ahsan

  3. Does this work on SQL 2008?
    I tried it and got the error:

    Msg 155, Level 15, State 1, Line 1
    'truncate_only' is not a recognized BACKUP option.

  4. hi i tried this in sql server 2008 enterpirse
    following error got
    Msg 155, Level 15, State 1, Line 2
    'truncate_only' is not a recognized BACKUP option.

Comments are closed.