Friday, November 15, 2013

SQL Server - what's using my log !

So you want to possibly shrink the log file  (not the database) because - oh well you do! It has grown for some reason and you don't really know what in God's name happened. So you go to SSMS right-click the database and shrink the file or run the DBCC ShrinkFile, right? But the log file won't shrink. Now before you jump on LOG IS ACTIVE - I need to take a backup. Let's look at what's currently using the log..ehh!

Here is the query:

select name, log_reuse_wait_desc  from sys.databases

Example result set:














So now you know what's going on with your log file. You may even find that 'REPLICATION'  is using log file even though there is no Replication set up for the database.

May be someone tried to set up replication and didn't remove it properly! So, you'll have to remove it properly and then shrink the log file, simple stuff right?

No comments:

Post a Comment