USE MyDB
ALTER DATABASE MyDB SET Recovery simple
GO
checkpoint
GO
DECLARE @LogFileLogicalName sysname
SELECT @LogFileLogicalName=Name FROM sys.database_files WHERE TYPE=1
DBCC Shrinkfile(@LogFileLogicalName,1)
GO
ALTER DATABASE MyDB SET Recovery FULL
There are surprisingly few articles on this on the Internet, so enjoy. And remember to do a full database backup right after shrinking the log file! Cause you won't be able to restore "to a point in time" once the log is truncated.


0 comments:
Post a Comment