Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS SQL Log File Too Large

Posted on 2014-01-30
5
Medium Priority
?
398 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 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 1000 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 23

Assisted Solution

by:Steve Wales
Steve Wales earned 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
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…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

971 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