Shrinking a SQL Transaction Log File

SQL2000Logo Every so often, I run out of drive space on my SQL Server.  The culprit ends up being the Transaction Log File (LDF) expanding to consume all available space.

My simple workaround is to shrink the log file with these SQL commands.
USE <database name>
GO
DBCC SHRINKFILE (<name of log file>,1)
GO
BACKUP LOG <database name> WITH TRUNCATE_ONLY
DBCC SHRINKFILE
(<name of log file>, 1)
GO

References:
DBCC SHRINKFILE (Transact-SQL)
SQL SERVER – Shrinking Truncate Log File – Log Full

Comments are closed.