Reducing the Database Log File Size

Hello All,

Today i’ll talk about how to reduce the file size of the Log file of your SQL Server Database.

Log Files tend to grow to an extent that it might eat up a lot of space on your drive and for me it went to an extent that my database was down due to lack of space on the drive.

So, no apps were able to dump any record into the database at all.

Well, we’ll have to live with it though as it seems.

Log Files can be cleared using a SQL Script

ALTER DATABASE  DATABASENAME
SET RECOVERY SIMPLE;
GO
— Shrink the truncated log file to 1 GB (You can shrink upto 1 MB).
DBCC SHRINKFILE (DATABASE_log, 1000); –LOG FILE NAME
GO
— Reset the database recovery model.
ALTER DATABASE DATABASENAME
SET RECOVERY FULL;
GO

Hope this works for you too!

Cheers!

Rohant K.

Advertisements