Link to home
Start Free TrialLog in
Avatar of nectarios777
nectarios777Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Errors in Shrinking the Transaction Log

Hello all,

I've been phasing a problem with my SQL Server for the last 4 months.
The transaction logs of all of my databases keep expanding enormously.
Right now one of my T-LOG files is 30 Giga and its just a small site with a few users
every day. I'm wondering what I'm I doing wrong or if I misconfigured something.

I'm trying to shrink my transaction log files using the following command, but I'm getting errors:

use dbxxx;
go
DBCC SHRINKFILE (dbxxx_Log, 1000);
GO


Here are the errors:

Msg 8985, Level 16, State 1, Line 1
Could not locate file 'dbxxx_Log' for database 'dbxxx' in sys.database_files. The file either does not exist, or was dropped.


I'm sure that the particular transaction log name is the one used by the database.

Any ideas?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ashok Kumar
Ashok Kumar
Flag of India 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 nectarios777

ASKER

Hello,

here is what I get after I execute the code above:

Msg 911, Level 16, State 10, Line 4
Could not locate entry in sysdatabases for database 'test_log'. No entry found with that name. Make sure that the name is entered correctly.
Msg 3013, Level 16, State 1, Line 4
BACKUP LOG is terminating abnormally.
Cannot shrink log file 2 (dbIAGBS_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.
use DATABASENAME;
go


declare @sysfilename varchar(255)
select @sysfilename =  rtrim(name) from sysfiles where fileid =2
BACKUP LOG DATABASENAME WITH TRUNCATE_ONLY
DBCC SHRINKFILE(@sysfilename , 1)
If the database log file size yet to reduce, then just restart sql service and then run the script. alternative way also can be to detach and attach, but hopefully not in production environment.
Thanks for your response.
So is there any way to set un auto-shrink to the log file in case it grows unexpectetly?

I have tried to keep its size restricted, but when it reaches the restricted size the website stops
working.

Thanks