How To: MS SQL Empty Database Log File

You will often find your database log file (.ldf) growing to a very large size, often larger than the databasie file (.mdf) itself.

Log files should shrink after a full backup, but this isnt always the case. Below is a quick command you can run to empty a database log file.

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

Note: 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.

See Also:
Truncate or Srink a large Log File
How to empty a SQL Server database transaction log file