Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 17th, 2007, 09:25 AM
Registered User
 
Join Date: Jan 2007
Location: eagan, mn, USA.
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.

Reply With Quote
  #2 (permalink)  
Old August 20th, 2007, 02:45 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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
Reply With Quote
  #3 (permalink)  
Old September 6th, 2007, 11:27 PM
Registered User
 
Join Date: Sep 2007
Location: Melbourne, , .
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.
Reply With Quote
  #4 (permalink)  
Old September 7th, 2007, 10:11 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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
Reply With Quote
  #5 (permalink)  
Old September 7th, 2007, 07:31 PM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:43 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.