Tuesday, August 7, 2012

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(<TransactionLogName>, 1)BACKUP LOG <DatabaseNameWITH TRUNCATE_ONLYDBCC SHRINKFILE(<TransactionLogName>, 1)GO
[Update: Please note, there are much more to this subject, read my more recent blogs. This breaks the chain of the logs and in future you will not be able to restore point in time. If you have followed this advise, you are recommended to take full back up right after above query.]

No comments: