Truncating Sql Server Log Files

It has been frequently seen in SQL Server, that despite the efforts of the DBAs, the Log Files will refuse to be truncated. However, the following snippet of T-SQL is most effective on it’s own.

USE DatabaseName
GO
DBCC SHRINKFILE(TransactionLogName, 1)
BACKUP LOG DatabaseName WITH TRUNCATE_ONLY
DBCC SHRINKFILE(TransactionLogName, 1)
GO

These are just a few of the sites I went to doing my research:
http://ss64.com/sql/dbcc_shrinkfile.html
http://msdn.microsoft.com/en-us/library/aa258824%28SQL.80%29.aspx
http://blog.sqlauthority.com/2010/05/03/sql-server-shrinkfile-and-truncate-log-file-in-sql-server-2008/

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s