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 Administration
 DBCC SHRINKFILE : T-log

Author  Topic 

hari_sql
Starting Member

22 Posts

Posted - 2010-03-25 : 06:34:13
Hi

My current DB Transaction log size (MS SQL Server 2005) is around 45GB.
I tried to shrink the T-log using DBCC SHRINKFILE (N'EmpDB_log' , 1). But the size of the T-log is not getting reduced. I tried the same from Management Studio interface also, but the same result. I have data being written continuously in to the DB, while the shrink operation is being performed. Can anyone please respond with why the size of the T-log is not getting reduced?!

Thanks and Regards,
Hari.

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-03-25 : 06:55:12
You need to check the recovery model of the database (in database properties). If the database is in Full- or bulk logged recovery model you need to take a transaction log backup before the logfile can be shrunk. If the recovery model is simple your log shouldn't keep growing unless you have some really large batch transactions goin or something. In that case you need to stop these transactions and then run a shrink on the file.

Please note that shrinking database files is generally considered bad practice and should be avoided unless something extraordinary has happened.

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page

hari_sql
Starting Member

22 Posts

Posted - 2010-03-25 : 07:43:36
Dear Lumbago

It is Full logged recovery. There is mirroring and log shipping enabled. But shrinking is done after the mirroring and log shipping are disabled. But still the T-log size is not shrinking!

Thanks & Regards,
Hari.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-03-25 : 07:50:06
Do you have any open long-running transactions that might be blocking the database from setting a checkpoint in the log? When was your last transaction log backup?

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page

hari_sql
Starting Member

22 Posts

Posted - 2010-03-25 : 08:33:03
Dear Lumbago

Bulk data is being written into the DB every minute.
And its been around 3 months since the last T-log backup was done.

Thanks & Regards,
Hari.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-03-25 : 08:48:26
Well...there you have it then. Do a t-log backup and then shrink the file. As I said in my initial post: " If the database is in Full- or bulk logged recovery model you need to take a transaction log backup before the logfile can be shrunk"

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-03-25 : 09:20:13
"log shipping enabled" ... "its been around 3 months since the last T-log backup was done"

Doesn't sound quite right ??
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-03-25 : 09:33:36
Totally doesn't make sense but I assumed log shipping was disabled on purpose so I didn't make any comments about it: "But shrinking is done after the mirroring and log shipping are disabled"

- Lumbago
If the facts don't fit the theory, change the facts. Albert Einstein
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-03-25 : 09:38:30
Yup, saw that, but read it that they were stopped just for the duration of trying to shrink the file.

If they have been stopped for 3+ months then they are not in use, eh?!!
Go to Top of Page

hari_sql
Starting Member

22 Posts

Posted - 2010-03-26 : 07:24:49
Guys,

Thank you for the inputs.
I was mentioned about a physical backup (copy/paste) of the T-log to the same system in the near future as part of trying out shrinking.

Regards,
Hari.
Go to Top of Page
   

- Advertisement -