Solved

MS SQL Log File Too Large

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

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 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