Manually truncate MS SQL 2005 log file (.LDF)

If MS SQL database Recover Model is set to “FULL” and regular full backups are not performed databases log files (.LDF) can grow very large.

If you are working with a production database make sure you know what you are doing as you may loose ability to restore your database to any point in time since your last backup. If production database backups and storage management are set up properly you should never need to truncate logs manually.

To manually truncate log file on test/development SharePoint_Config database:

1. Open SQL Server Management Studio and run following SQL query:
USE SharePoint_Config
BACKUP LOG SharePoint_Config WITH TRUNCATE_ONLY

This will truncate log file but won’t reduce actual file size.

2. To shrink actual file run:
USE SharePoint_Config
DBCC SHRINKFILE (N’SharePoint_Config_log’, 50)
50 – Log file target size in MB.
OR
SQL Server Management Studio > Databases > SharePoint_Config > Tasks > Shrink > Files

3. To prevent future growth of the log file run:
USE SharePoint_Config
ALTER DATABASE SharePoint_Config SET RECOVERY SIMPLE

OR
SQL Server Management Studio > Databases > SharePoint_Config > Properties > Options > Recovery Model > Simple

Microsoft SQL Server 2005


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *