Friday, February 24, 2012

Cannot shrink log file

I know this is an age old question. I've looked through the posts and don't
find an answer.
I did a log backup this morning with the truncate option. Now I run "dbcc
shrinkfile" and get this:
Cannot shrink log file 2 (BSMOrders_Log) because all logical log files are
in use.
What causes this? I thought the backup would delete this data so the file
could be shrunk. It is still sitting at 12GB....Show all logical log files using DBCC Loginfo(<database id> ). If status is 2
for last log file then you will not be able to shrink it. Status 2 means it'
s
an active log and currently being used. In that case you can run some dummy
transactions to bring it to 0. Also you can look for any open transactions
that are not committed yet by using DBCC OPENTRAN
"Tim Greenwood" wrote:

> I know this is an age old question. I've looked through the posts and don
't
> find an answer.
> I did a log backup this morning with the truncate option. Now I run "dbcc
> shrinkfile" and get this:
> Cannot shrink log file 2 (BSMOrders_Log) because all logical log files are
> in use.
> What causes this? I thought the backup would delete this data so the file
> could be shrunk. It is still sitting at 12GB....
>
>|||Hey Bob
When you said "you can run some dummy transactions to bring it to 0",
could you please describe what does that really mean and how can
somebody run a transaction (can you please provide some sample SQL).
Sorry for lack of my knowledge on that
Thanks
PP
Bob wrote:[vbcol=seagreen]
> Show all logical log files using DBCC Loginfo(<database id> ). If status is
2
> for last log file then you will not be able to shrink it. Status 2 means i
t's
> an active log and currently being used. In that case you can run some dumm
y
> transactions to bring it to 0. Also you can look for any open transactions
> that are not committed yet by using DBCC OPENTRAN
> "Tim Greenwood" wrote:
>|||Lookup 'shrinking the transaction log' in Books Online for a detailed
explanation.
Paul Randal
Lead Program Manager, Microsoft SQL Server Storage Engine
http://blogs.msdn.com/sqlserverstor...ne/default.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
<prabhupr@.hotmail.com> wrote in message
news:1152712375.701470.10780@.i42g2000cwa.googlegroups.com...
> Hey Bob
> When you said "you can run some dummy transactions to bring it to 0",
> could you please describe what does that really mean and how can
> somebody run a transaction (can you please provide some sample SQL).
> Sorry for lack of my knowledge on that
> Thanks
> PP
> Bob wrote:
>

No comments:

Post a Comment