Solved

MS SQL Log File Too Large

Posted on 2014-01-30
5
375 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

622 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