by zebsadiq
27. February 2014 00:04
Recently I discovered that a post that I wrote earlier about shrinking SQL Server log files is not valid for SQL Server 2008 onwards.
In particular, the tuncate_only command is no longer valid in SQL Server 2008.
Here is some code that you can use instead, however DO NOT USE THIS STATEMENT IN THE PRODUCTION ENVIRONMENT. This code should only be run in a low risk development environment for which a full backup is present:
USE [MyDatabase]
GO
ALTER DATABASE [MyDatabase] SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE(MyDatabase_Log, 1)
ALTER DATABASE [MyDatabase] SET RECOVERY FULL WITH NO_WAIT
GO