Solved

MS SQL Log File Too Large

Posted on 2014-01-30
5
364 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
[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 23

Expert Comment

by:Patrick Bogers
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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Suggested Solutions

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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