Thursday, January 17, 2013

MicroSoft SQL Server - Clear the transaction logs

Shrinks the size of the log files in the specified database.

USE DBNAME
GO

-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE DBName SET RECOVERY SIMPLE;
GO

-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (DBName_Log, 1);
GO

-- Reset the database recovery model.
ALTER DATABASE DBName SET RECOVERY FULL;
GO





--
Jagadeesh
M: +61 425359215  | H: +61 296881489