Sunday, October 27, 2013

Simple SQL Query to Shrink SQL Server Database Log File Size

When SQL Server Service stopped working due to insufficient disk space, one of the possible culprit may be the SQL Server Database Log File that has grown to be very large.

Here is some simple SQL Query to shrink the size of the log file:

====
Use mydatabasename;
GO

ALTER DATABASE mydatabasename
SET RECOVERY SIMPLE
GO

DBCC SHRINKFILE (mydatabasename_Log, 1);
GO

ALTER DATABASE mydatabasename
SET RECOVERY FULL;
GO
====

Waring: The above query will truncate your database log!

1 comment:

  1. I really enjoy reading of your article. I wanted to inform you that you have people like me who appreciate your work. sms bomber apk editor no wifi games

    ReplyDelete