Solved

MS SQL Log File Too Large

Posted on 2014-01-30
5
339 Views
Last Modified: 2014-02-13
I have two databases with very large Transaction Log Files (67 gb and 114 gb).  I have tried to shrink them but that has barely reduced them.  What are my options?  Can I delete them and rebuild new ones?
0
Comment
Question by:Roger-Gullo
5 Comments
 
LVL 19

Expert Comment

by:Patricksr1972
ID: 39823308
Hi

Put the recovery mode to full and run a backup, this will purge the logs.
After put the recovery mode back to original.
0
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39823672
try the below script
NOTE it will try to shrink all the log files in the server

-- shrink the log files
declare @ssql nvarchar(4000)
set @ssql= '
        if ''?'' not in (''tempdb'',''master'',''model'',''msdb'') 
		begin
		select ''[?]''
        use [?]
		ALTER DATABASE [?] SET RECOVERY SIMPLE; 
        declare @iLogFile varchar(1000),@tsql varchar(2000);
        select @iLogFile = name from sys.database_files where type_desc = ''log'';
		select @iLogFile
        set @tsql = ''DBCC SHRINKFILE(''+@iLogFile+'', 1) '';
        exec(@tsql);
		ALTER DATABASE [?] SET RECOVERY FULL; end'
exec sp_msforeachdb @ssql

Open in new window

0
 
LVL 15

Accepted Solution

by:
JimFive earned 250 total points
ID: 39824163
You have to do a transaction log backup and then you will be able to shrink the log files.  If you are in FULL recovery mode you should be doing transaction log backups more often than full backups.  This will help keep your log file from growing so much.  (In a high volume environment you may want to do transaction log backups every 15 minutes, but the timing is something you need to evaluate.)
0
 
LVL 22

Assisted Solution

by:Steve Wales
Steve Wales earned 250 total points
ID: 39824221
Have a read of this article:

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/A_11077-How-to-shrink-a-bloated-log-file.html

Backing up the database does not mark your transaction log as being able to be reused.  If you're in Full recovery mode and not doing transaction log backups, your log will grow forever until you run out of disk space.

Regular log backups stop that from happening.  The article describes how to shrink your log file (back it up, shrink it, do regular log backups) and has some links to other articles on how to resize your log file to match your transaction load and to size appropriately and not end up with excessive VLF's.
0
 

Author Closing Comment

by:Roger-Gullo
ID: 39858111
Steve Wales' linked article was very informative.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

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

17 Experts available now in Live!

Get 1:1 Help Now