Solved

Transaction Log for database XXX is full

Posted on 2016-08-31
5
66 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 12

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 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Nested cursor  in SQL 9 94
SQL Query 34 80
Error running stored procedure 11 14
Sql Query with datetime 3 0
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

911 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

20 Experts available now in Live!

Get 1:1 Help Now