Paul Gu | Blog

sharing is caring

MS SQL SERVER – Shrinking Truncate Log File (Log Full)

Is it impossible to shrink the Trucated Log file?

Yes, following code always shrinks the Trucated Log File to minimum size possible.

1) Replace DatabaseName with your database name
2) Replace TransactionLogName to database log name

USE DatabaseName
GO

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

Is is simple?

Next Post

Previous Post

Leave a Reply

© 2024 Paul Gu | Blog

Theme by Anders Norén