Tuesday, September 28, 2010

SQL Server 2005 - Truncate the Log file

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

DBCC SHRINKFILE will shrink the unused space.
BACKUP LOG WITH TRUNCATE_ONLY will take the backup of existing transaction to log and will delete all the previous log.
DBCC SHRINKFILE will shrink the unused space.

No comments: