Saturday, February 18, 2012

Truncating Transaction Logs in SQL SERVER

Truncating transacation logs!!! Normally you need to find why your transactional logs are growing. The major reason would be that your transaction logs are not getting backed up.

First thing is to check your database recovery model and if you have it as 'FULL' and you deal with too many transactions within the day then start backing up your transaction logs otherwise change your recovery model to 'SIMPLE' (not suitable for databases dealing with large transactions)

Before you change the recovery model you need to truncate your logs.

USE [DatabaseName]
GO

ALTER DATABASE [DatabaseName] SET RECOVERY SIMPLE
GO

DBCC ShrinkFile('[Database log file Logical name]',100)
GO

Note: For Data Warehouse Databases, it is recommended to use 'SIMPLE' recovery model

No comments:

Post a Comment