SQL Shrink Log File

SQL SERVER – Shrinking Truncate Log File – Log Full

Sometime, it looks impossible to shrink the Truncated Log file. Following code always shrinks the Truncated Log File to minimum size possible.

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

http://blog.sqlauthority.com/2006/12/30/sql-server-shrinking-truncate-log-file-log-full/

Advertisements

3 Comments

  1. This way for 2008 too:

    USE TootleCFD
    GO
    ALTER DATABASE TootleCFD SET RECOVERY SIMPLE WITH NO_WAIT
    DBCC SHRINKFILE(TootleCFD_lOG, 1)
    ALTER DATABASE TootleCFD SET RECOVERY FULL WITH NO_WAIT
    GO

    Reply

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 )

Google+ photo

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

Connecting to %s