Shrink SQL Server 2008

Normally when a database in Microsoft Sql Server 2008 is created the recovery model is full and that causes huge disk space usage and with usage of database the log file increases in size.

Some times you may need to clean the log file, so here you go.

USE [DATABASE_NAME];
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE  [DATABASE_NAME]
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE ( [DATABASE_LOG_FILE_NAME], 1);
GO
-- Reset the database recovery model.
ALTER DATABASE  [DATABASE_NAME]
SET RECOVERY FULL;
GO

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.