Link to home
Start Free TrialLog in
Avatar of djlurch
djlurch

asked on

LDF Log file is 30.6 GB - Initial Size somehow set to 30 GB and it can't be changed

When one of my sql databases was set up, the default initial size got set to 30GB (!). I have tried shrinking the log file, but it won't shrink to below about 30GB. I have tried changing the default initial size to 50MB, but it reverts back to 30 GB when I take any actions. I have tried backing up the database and restoring it from the backup...and it re-incorporates the 30GB file.

I have tried the following SQL query but it gives the following error. Note that I tried limiting it to a single user.

SQL:

USE [dbname]
DECLARE @FILEID int

SELECT @FILEID = file_id FROM sys.database_files WHERE type = 1

DBCC SHRINKFILE(@FILEID)

ERROR:

Cannot shrink log file 2 (dbname_log) because all logical log files are in use.

(1 row(s) affected)
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

I'm stuck. I've had one SQL vendor try to help, but he's stuck. Help!
ASKER CERTIFIED SOLUTION
Avatar of ezaton
ezaton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of David Todd
David Todd
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of djlurch
djlurch

ASKER

I ran the code in this thread:

https://www.experts-exchange.com/questions/22392154/truncate-log.html?sfQueryTermInfo=1+file+log+truncat

DBCC SHRINKFILE(MyDatabase_Log, 1)
Go
BACKUP LOG MyDatabase WITH TRUNCATE_ONLY
Go
DBCC SHRINKFILE(MyDatabase_Log, 1)

It worked like magic! It seemed to change the initial size to 1 MB. I cannot change it from the 1 MB size, but my issue seems to be resolved for the most part.

Let it autogrow, and it will grow. You can limit its maximal size.
Avatar of djlurch

ASKER

Thank you to both of you. dtodd gets a few points since his answer is probably another solution. Exaton helped me find the right search terms.
With pleasure :-)