Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't my transaction log shrink?

Database and Log Files

Why won't my transaction log shrink?

by  foxdev  Posted    (Edited  )
Even though you have run DBCC SHRINKFILE and similar steps you may find that the log file will not shrink.

Why won't it shrink?
First, make sure you've backed up the log file. SQL Server doesn't want to truncate a log file that's not been backed up, and this is the behaviour we would want. So, the first step is to backup the log file, even if you just toss the backup. (thanks to jnicho02)

Run the command [tt]DBCC LOGINFO[/tt] against the desired database and look for entries with the Status=2. A Status of 2 indicates that this portion of the log is active. SQL Server cannot truncate a log before this active portion. If the active portion is at or near the end of the log file, this will prevent the log from being shrunk.

How can I make it shrink?
As with all things, the natural way is best. Once you've backed up the transaction log, future transactions will eventually force the active portion to wrap around to the beginning of the file. When that happens, the log will be shrunk.

I can't wait - I want it to shrink now!
If you must shrink the log, and you don't have a production database (or point-in-time recovery is not important to you), this site contains the steps needed to force it to shrink:

http://www.broad-lea.com/sql_server/sql_reduce_log_size.html
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top