Search This Blog & Web

Monday, July 27, 2009

How to shrink database log file size

There are 2 ways to shrink db file size using SQL Server

Way one: Using SQL Server job or Maintainess plan and by setting log shrink to 10%.

but some time we face problem that our log file do not shrink even if job runs successfully. This is because this shrink operation shinks free and unused log file update 10%. if we want to shrink db file at our desired percentage then we have to use DBCC command and manually enter remaing size of log file. like follows

Second Way:
DBCC SHRINKDATABASE ('MYDATABASENAME',10);

This command shrinks database log file size to 10Mb.

Caustion: before using this please take a backup first.

you can take backup using this command

backup log 'dbname' with truncate_only

No comments: