Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 DBCC Shrinkfile

Author  Topic 

munkdogg
Yak Posting Veteran

53 Posts

Posted - 2006-08-29 : 11:18:33
Hello,

I am attempting to shrink the disk size of my db log files, using the following command;

dbcc shrinkfile (filename,truncateonly)

The command completes successfully, but the log file size remains unchanged. Am I missing something here? Should the file size be reduced?

nr
SQLTeam MVY

12543 Posts

Posted - 2006-08-29 : 11:31:26
see
http://www.nigelrivett.net/SQLAdmin/TransactionLogFileGrows_1.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

munkdogg
Yak Posting Veteran

53 Posts

Posted - 2006-08-29 : 11:44:35
quote:
Originally posted by nr

see
http://www.nigelrivett.net/SQLAdmin/TransactionLogFileGrows_1.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.



awesome, thank you!
Go to Top of Page

lotsosoul
Starting Member

1 Post

Posted - 2014-01-15 : 21:08:20
I'm having the same problem! The document referenced basically goes over what I've read on Microsoft doc's, but that didn't help anything. Why isn't the document shrinking? Is there anything that would stop that from happening?
Go to Top of Page

jeffw8713
Aged Yak Warrior

819 Posts

Posted - 2014-01-16 : 16:25:33
A couple of things...

First, run a DBCC LOGINFO in the database. The Status column will show you whether or not the VLF is in use. Status = 2 is in use and 0 is available.

If the last VLF listed is in use, you cannot shrink the file beyond that point. When the database is in full recovery model - you have to perform a transaction log backup to mark the VLF's as available and roll over to the VLF's at the beginning of the file. If the database is in simple recovery model - you need to perform a checkpoint.

To shrink the log file, you also need to specify the size to shrink to - as in: DBCC SHRINKFILE(log_file, 8000)

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2014-01-20 : 08:48:01
IME experience you sometimes have to:

backup the Log
Create one/more new transactions
backup the Log again

then if can be shrunk.

I suspect that something is adding transactions to the log as the backup is happening, and something added is "after" the end of the log backup, but before earlier transactions have been released for re-use, after the first backup new transactions will start reusing the early part of the file, now marked as available for reuse, and it needs the second log file backup to release the few transactions at the end of the file.

Long story short: be prepared to make two log backups, rather than just one, to be able to release all the space you are hoping to.
Go to Top of Page
   

- Advertisement -