Solved

Transaction Log for database XXX is full

Posted on 2016-08-31
5
58 Views
Last Modified: 2016-09-12
Hi Experts,

I am working with SQL 2008 and have an issue with the transaction log for the database being full. I ran a check on the log_reuse_wait_desc and the error was LogBackup and the log_reuse_wait=2.

How do I resolve this issue?

Thanks
0
Comment
Question by:Member_2_7964761
5 Comments
 
LVL 39

Expert Comment

by:lcohan
ID: 41778714
USE testdb
GO
CHECKPOINT
GO
DBCC SHRINKFILE (N'testdb_log' , 0, TRUNCATEONLY)
GO
-- or:
BACKUP LOG testdb TO DISK='NUL:'

But you need to have a FULL backup prior to this just in case.
0
 
LVL 11

Expert Comment

by:Nakul Vachhrajani
ID: 41778715
Please check the recovery mode of the database. If it is the full recovery model, the only way to free up space in the log is to take a log backup.

Is this a production database, or a database that is primarily used only for ad-hoc development and testing? If it is used only for ad-hoc purposes, you can evaluate setting the recovery model to "Simple". Do keep in mind though that setting the recovery model to "simple" will impact your ability to recover the database in case of a failure.
1
 
LVL 39

Expert Comment

by:lcohan
ID: 41778718
Also you need to check the recovery model and if that is FULL you must perform regular FULL + T-Log backups to reclaim T-log space otherwise it will get full again.
0
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 250 total points
ID: 41778814
You have two choices.

1) Take a log backup.  Depending on the log size, this could take a long time.  While you're doing that the db will remain unuseable.  But it keeps the backup/log chain intact.  If you would really ever want to apply an overgrown log to recover the db, you need to use this method.

2) Put the db into SIMPLE recovery model and shrink the log file.  Then, if you need to, set recovery back to FULL and immediately (or asap) take a full db backup.

USE [XXX]
ALTER DATABASE [XXX]  SET RECOVERY SIMPLE;
CHECKPOINT;
DBCC SHRINKFILE (2, 4096);
EXEC sp_helpfile /*verify that the log file is really smaller*/

Btw, learn to use SQL commands such as those above to work on the log.  Do not use the SSMS gui for this, as it can be flaky.  Besides, it's easier to repeat if you use commands, and you'll have a record of exactly what was done, which you won't get from a gui.
0
 
LVL 3

Assisted Solution

by:Daniel Jones
Daniel Jones earned 250 total points
ID: 41779260
First change Recovery Model to Simple
  • Database Propertise > Options > Recovery Model > Simple

Then Shrink Files Log
  • Database > Shrink > Files > Log

Then check your db log file size at
  • Database Propertise > Files > Database Files > Path

To check full sql server log: open Log File Viewer at
  • SSMS > Database > Management > SQL Server Logs > Current

Do you have Enable Autogrowth and Unrestricted File Growth for the log file. You can edit these via
  • SSMS > Database Properties > Files
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now