Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2007, 09:25 AM
Registered User
 
Join Date: Jan 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Decrease the log file (.ldf) size

Hi All,

   My SQL Server Database .ldf size is increasing. I want to decrease the size of the log file (.ldf). I tried with DBCC SHRINKFILE, Is there any other way.

   Please give me an idea.

Thanks in advance.

 
Old August 20th, 2007, 02:45 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Do you want to shrink it once or prevent it from growing? When you create a database you can set it to use Simple logging mode which I believe will reduce the size of the transaction log, but doesn't provide as much failure protection. This is usually acceptable for development DBs.

You could set up a maintenance plan to run the database shrink on a periodic schedule.

-Peter
 
Old September 6th, 2007, 11:27 PM
Registered User
 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The log file will not shrink until it has been backed up at least twice along with the databse. Once that has been done it will shrink - Check your maintenance plan that both the database & log file are regularly backed up.

The backup processes mark the log with what parts can be cleaned up and what parts are needed to recover the database.
 
Old September 7th, 2007, 10:11 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

KiwiStonewall-

Is there some action aside from a backup that can be done that marks log parts as cleanable? Does detaching a database commit everything to it such that the log can be shrunk?

-Peter
 
Old September 7th, 2007, 07:31 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

From BOL... my favorite resource :D

Truncating the transaction log:
Code:
BACKUP LOG { database_name | @database_name_var } 
{ 
    [ WITH 
        { NO_LOG | TRUNCATE_ONLY } ] 
}
NO_LOG | TRUNCATE_ONLY
Removes the inactive part of the log without making a backup copy of it and truncates the log. This option frees space. Specifying a backup device is unnecessary because the log backup is not saved. NO_LOG and TRUNCATE_ONLY are synonyms.

After backing up the log using either NO_LOG or TRUNCATE_ONLY, the changes recorded in the log are not recoverable. For recovery purposes, immediately execute BACKUP DATABASE.


And, no, I've never heard nor have ever seen that you need to do at least 2 backups to clear the log... it has always worked on the first backup on every database I've ever worked with.


--Jeff Moden





Similar Threads
Thread Thread Starter Forum Replies Last Post
Decrease newsletters nabeelalkaff BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 December 14th, 2007 11:29 PM
Can't get Log to write the Log.txt file jnbutler BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 3 July 31st, 2007 04:04 AM
Pubs.ldf File Not In Download? JimWF BOOK: Beginning ASP.NET 2.0 and Databases 0 May 25th, 2007 11:28 AM
text increase/decrease ... jstewie Javascript How-To 0 July 12th, 2005 12:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.