Sign up ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a database which had mdf size of 350 MB and ldf size 4.9 GB When i try to shrink the log file it's not shrinking. I know shrinking a database is not good and it should not be done. But still i am trying to do it for shrinking the log file. The recovery model is set to FULL.

Then i followed some steps:

When I run

dbcc SQLPerf(logspace) 

i found that logsize is 4932 MB and Log space used is 98.76% So large amount of (98%) of log is using now. Then I tried this command

use <databasename>  dbcc loginfo

Now almost all VLF has status 2 which means all are in use. then I tried to take log backup. After log backup also shrinking didnt reduce the size. Then i changed recovery model to simple and then tried shrinking.But this also didn't help. Also I checked for open transaction

dbcc opentran (database)

and found that no transaction is open now. So what is making the database which does not allow me to shrink the log size.How can i solve this?

share|improve this question

6 Answers 6

Read How to Shrink SQL Server log for an explanation how the circular nature of the log may prevent shrink after truncation. Is possible that you log's last LSN point into a VLF that is at the tail of the LDF. Counter intuitively you must advance the log, by generating log writes, to allow it to shrink.

share|improve this answer
But problem i encountered is different.Please see my answer below – Navaneeth Apr 30 '13 at 14:33

Steps for shrinking the log are going to be

Backup transaction log through either SSMS or T-SQL and then perform a shrink

commands for SSMS are under the tasks if you right click the database name

BACKUP LOG <Databasename> TO DISK N'<path\database_log.ldf';


You will probably have to do this multiple times

If there is a transaction or job blocking the action, use Activity monitor to identify the process and kill it, or use the SQL Agent job activity monitor to end the job.


share|improve this answer
But problem i encountered is different.Please see my answer below – Navaneeth Apr 30 '13 at 14:33
Glad to hear you got it figured out, thanks for the update! – Cougar9000 Apr 30 '13 at 14:51
up vote 3 down vote accepted

Here is the answer to my own question.

Run the below query to get information about the log files.

select log_reuse_wait_desc from sys.databases where name = 'DBName' 

It will give output if there relevant rows. I got the following output:


There were some replication-related objects remaining in the database even after removing the replication.

To remove the replication from the database, sp_removedbreplication can be used. But it didn't work for us as replication was not active at the time and actually replication had been removed long before.

The solution was to import the database contents to another database using the import option of SQL Server.

share|improve this answer

You need to create a backup first, dependent on the backup model that is set up for the database before you can shrink the database.

You can try running this:

USE <databasename>

BACKUP DATABASE <databasename> TO DISK '<absolute path goes here>\<databasename>.bak';

Or you can do that from SSMS and use the graphical tools available (see here for details:

Once you've backed up your database you can compress it. However, shrinking the database is not a good idea since heavy index fragmentation will occour and searching for data will become slow.

Hope this helps.

share|improve this answer
I know how to do backup and truncate the log and reduce log file size. But for this database i am having problem.I just ran query select log_reuse_wait_desc from sys.databases where name = 'dbname' and found that replication is causing the problem .But i dont have replication set on it. So how to remove the repliaction from this db which is shown in log reuse wait_desc? – Navaneeth Apr 30 '13 at 12:44
Which SQL Server version are you using? – Toni Kostelac Apr 30 '13 at 12:58
Replication might be set as a Job, so open up the SQL Server Agent folder, and Expand the Jobs folder, check to see if there is a replication job set up and if so turn it off by right-clicking and selecting Stop job – Toni Kostelac Apr 30 '13 at 13:01
If you are using SQL Server 2005 and up then sp_removedbreplication 'DB_NAME' will remove replication. For sql server 2000 .. refer to… – Kin Apr 30 '13 at 13:14
But problem i encountered is different.Please see my answer – Navaneeth Apr 30 '13 at 14:34

I have found that I have to perform 2 or 3 backups of both the database and the transaction log to get the transaction log to actually reduce in size. I have a database that was created with Full recovery model. Every night it performs backups of the database and the transaction log but inevitably the transaction log seems to continually grow over 2-3 weeks. When the remaining disk space gets to 1GB I will see that the transaction log is about 30GB. I followed the steps recommended by Microsoft and after the 4th or 5th iteration of backing up both the database and the transaction log the transaction log will finally release its extra space and shrink. Then I go back and delete the multiple backups I have created.

share|improve this answer
I think you are doing something wrong. If you take backup of log properly then unused log should be truncated. The commands given in my question may help you to solve the problem. – Navaneeth Jan 7 '14 at 6:40

My work around for the Replication that is blocking shrinking log file is:

  1. Set DB Recovery Model to Simple
  2. Take DB offline
  3. Create backup of log file (just in case)
  4. Delete log file
  5. Bring DB online

In my case it worked. After bringing DB online log was created automatically and it's size was 512kb instead of 70GB. But this is only a workaround. The root problem is not resolved. In my case we are using replication.

share|improve this answer
This is terrible advice, never delete your transaction log, all sorts of problems can come from this such as corruption – Tom V Aug 31 at 8:53

protected by Paul White Aug 31 at 9:23

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.