SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Shrink log file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pkkalra
Starting Member

Australia
5 Posts

Posted - 03/24/2014 :  00:27:47  Show Profile  Reply with Quote
I am trying to shrink the log file which has grown to 21 GB. I can see that only 25% of it is being used and rest is free space sitting there. I wanted to reclaim this space.
Our recovery model is FULL and cannot be changed to SIMPLE as it is being synchronized to a backup server.

I have tried the following:-
Taken full backup, transaction log backup and then doing shrink log file. I am mainly doing it via SSMS (Management studio) as I am not an expert in DBA stuff ( I am a developer).

File size is same and not reduced at all.

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2019 Posts

Posted - 03/24/2014 :  02:48:29  Show Profile  Visit jackv's Homepage  Reply with Quote
To decrease the transaction log file size - use the ALTER DATABASE ... MODIFY FILE option , use these instructions - http://www.sqlserver-dba.com/2013/02/modify-sql-transaction-log-file-size-increase-or-decrease.html

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page

pkkalra
Starting Member

Australia
5 Posts

Posted - 03/27/2014 :  01:27:02  Show Profile  Reply with Quote
ALTER DATABASE [DB] MODIFY FILE command didn't work. It seems like you can increase it but can't reduce it.

Error:
MODIFY FILE failed. Specified size is less than current size.

ALTER DATABASE Docprep MODIFY FILE (NAME = Docprep_log, SIZE = 1000MB)
Go to Top of Page

pkkalra
Starting Member

Australia
5 Posts

Posted - 03/27/2014 :  01:59:03  Show Profile  Reply with Quote
Finally resolved by following instruction from another forum. Basically you have to do twice in a row.

1. Make sure no open connections - DBCC OPENTRAN
2. Take Full backup
3. Take Transaction log backup with truncate
4. Shrink log file using DBCC SHRINKFILE
5. Repeat 3 & 4 again.

Voila! Log file is 10 MB now.
Go to Top of Page

jackv
Flowing Fount of Yak Knowledge

United Kingdom
2019 Posts

Posted - 04/01/2014 :  01:49:01  Show Profile  Visit jackv's Homepage  Reply with Quote
In the link I sent you there is a clear reference to first commit a shrinkfile , in step 3 , before you commit the ALTER DATABASE statement

If you attempt a ALTER DATABASE with MODIFY FILE you'll get this error

Msg 5039, Level 16, State 1, Line 1

MODIFY FILE failed. Specified size is less than or equal to current size.

To decrease the transaction log file size log , truncation must occur to free disk space. To reduce the log file physical size shrink to eliminate incative virtual log files
-- check there are no active transactions
USE sizetest
GO
dbcc shrinkfile(sizetest_log,TRUNCATEONLY)
GO
ALTER DATABASE sizetest
MODIFY FILE
(NAME = sizetest_log,
SIZE = 1MB);
GO






Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000