Tuesday, June 21, 2011

Shrink Current Log file

Useful in lengthy deployment scripts in conjunction with CHECKPOINT commands
/*
Shrinks log file for current database
Useful for index deployment script
*/
DECLARE @logfilename NVARCHAR(50)
SELECT @logfilename = name FROM sysfiles WHERE fileid = 2
DBCC SHRINKFILE (@logfilename , 0, TRUNCATEONLY)

No comments: