Solved

Transaction Log for database XXX is full

Posted on 2016-08-31
5
127 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 40

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 13

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 40

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:
Scott Pletcher 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 4

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

749 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