Skyscraper

miércoles, 26 de septiembre de 2012

Truncate LOG in a SQL Server 2008 Database

Today I've got a problem with a SQL Server 2008 Database again with the transaction log, which was full and generating errors in the business processes.

In an old entry I posted how to solve the problem, but in SQL Server 2005  Using the scripts for 2005 in SQL Server 2008, it will generate this error:

'TRUNCATE_ONLY' is not a recognized BACKUP option.

So, the solution in a SQL Server 2008 Database is to use this script:

USE ReportServerTempDB -- Database

ALTER DATABASE ReportServerTempDB SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE( ReportServerTempDB_log, 1) -- Parameters are: Logical Name of the file, percent occupied
ALTER DATABASE  ReportServerTempDB  SET RECOVERY FULL WITH NO_WAIT
GO

Like the old one, it has been tested and works fine.

To learn more about this, check this link from Pinal's Dave Blog: Original Page