Solved

SQL 2012 database log file too big, no disk space

Posted on 2016-08-17
11
41 Views
Last Modified: 2016-08-26
Dear all,

I have MS SQL 2012 server and the transaction log file has grown too big and the partition where the log file resides is out of space. Unable to run queries due to this issue. Any help on what best to do in this scenario would be appreciated.

Dee
0
Comment
Question by:ghco
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 45

Expert Comment

by:Vitor Montalvão
Comment Utility
Are you performing transaction log backups? If you weren't then that explains the transaction log being growing without any kind of truncation.
So to solve your issue you'll need to perform ASAP a transaction log backup and then schedule regular transaction log backups.
0
 
LVL 25

Expert Comment

by:Lee Savidge
Comment Utility
First of all why has this happened? Is the recovery model set to full or simple? If set to full, you MUST back up the database AND transaction log as part of your maintenance schedule.

If you don't your log file will simply increase until it runs out of disk space. This is perhaps the single most common problem that people face with a database.

So, what can you do? Well, if the disk is full, the application is not working, so try and do a database back up and then a transaction log backup to a different partition. Then when you've backed the transaction log up, you will need to shrink it.

https://msdn.microsoft.com/en-GB/library/ms189493.aspx

Try that, then come back to let us know if it has worked. There are things you can do if it doesn't work so don't worry.
0
 

Author Comment

by:ghco
Comment Utility
Thanks for the quick respond, the recovery model is set to simple. Will try what you suggested and let you know the outcome.

As an alternative can the log file be moved to another partition while the database is active?
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
Comment Utility
If the database is set to Simple then you can't perform transaction log backups. I'm wondering what can made the transaction log growing too much in a Simple Recovery model database. How big is the database and the transaction log file?

For moving a transaction log location you'll need to detach the database, copy the transaction log file to the new location and re attach the database.
0
 

Author Comment

by:ghco
Comment Utility
The database grew from 3GB to 40GB and the log file is 45GB. Apparently there was a massive entry to database table that wasn't necessary which made it grew, have tried deleting those entries but script wouldn't run because of the disk space issue.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 45

Expert Comment

by:Vitor Montalvão
Comment Utility
A massive data task can really justifies the grow but then it would empty the transaction log when the task is done. Mind that emptying the tlog is not the same that shrinking it so it may be your case. Did you try to Shrink the transaction log to see if you can recall any free space? If not then it means that the transaction it still active (still running or waiting for a commit/rollback).
0
 
LVL 26

Expert Comment

by:Zberteoc
Comment Utility
Use this script to shrink the log file:
USE [YourDatabase] 

ALTER DATABASE [YourDatabase] SET RECOVERY SIMPLE WITH NO_WAIT 

DBCC SHRINKFILE(N'YourDatabase_log', 1) 

Open in new window

where YourDatabase_log should be the logica file name of the transaction log file.
0
 
LVL 69

Expert Comment

by:ScottPletcher
Comment Utility
Yes, use commands, not the gui, to shrink the log file.

USE [db_name]
DBCC SHRINKFILE(2, 4096)

That will shrink it to 4GB.  I wouldn't shrink too small, because when the log is forced to grow again, that will be very bad for performance.

Also, check to be sure that nothing is preventing the log from shrinking/being reused, with this command:

DBCC OPENTRAN
0
 

Author Comment

by:ghco
Comment Utility
Found an MSDN link that shows how to shrink the database/log file from the SQL Management Studio so this worked for us. Thanks for all the help.

https://msdn.microsoft.com/en-GB/library/ms190757.aspx
0
 
LVL 26

Accepted Solution

by:
Zberteoc earned 500 total points
Comment Utility
In that article under "Using Transact-SQL" section is exactly what I posted as a solution at: 41759429
0
 
LVL 7

Expert Comment

by:Jason clark
Comment Utility
By querying the sys.databases catalog view you can see information describing the reason your log file may be waiting on truncate/reuse. see here to know other reasons for that: http://www.sqlmvp.org/transaction-log-is-too-big-or-growing-unexpectedly/
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

763 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

11 Experts available now in Live!

Get 1:1 Help Now