Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 October 8th, 2003, 08:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default More backup musings

Hi all,

Its my understanding that when I perform a full backup, or even a transaction log backup using the full recovery model, that all committed transactions are cleared out of the log. I notice, however, that after performing a backup the physical size of the transaction log on disk remains the same. I have the log set to auto-grow. So either:

1. The physical size of the log following a backup doesn't shrink from the size it has expanded to, but its emptied of committed transactions nonetheless, or

2. I'm doing something wrong.

Any insights?

Thanks,

Bob

 
Old October 9th, 2003, 08:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

When you do a backup (in full recovery mode), you only truncate the log, you don't actually physically shrink its size. Truncating the log simply marks the committed entries as unused and available. To physically shrink the file, you must execute a DBCC SHRINKDATABASE statement, or a DBCC SHRINKFILE statement referencing a log file. The log file is also physically shrunk if the autoshrink option is on and the database autoshrinks.

See BOL table of contents SQL Server Architecture, DataBase Architecture, Physical DataBase Architecture, Transaction Log Architecture, Shrinking the Transaction Log (whew!).

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old October 9th, 2003, 12:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Thanks Jeff,

I'll have a look at the references. I also pulled the following off another forum last night where some folks are talking about something similar. Looks like it might do the trick:

CREATE PROCEDURE [DBO].[usp_Truncate_Log] AS
BEGIN
    EXEC sp_dboption 'DB_NAME', 'trunc. log on chkpt.', 'TRUE'
END
BEGIN
    CHECKPOINT
END
BEGIN
    EXEC sp_dboption 'DB_NAME', 'trunc. log on chkpt.', 'FALSE'
END
BEGIN
    DBCC SHRINKFILE(LogFileName,1)
END

Thanks again,

Bob

 
Old October 9th, 2003, 02:49 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

From BOL:

"The trunc. log on chkpt and select into/bulkcopy database options are supported in SQL Server 2000 for backward compatibility purposes, but may not be supported in future releases."

Use at your own risk...

That whole mechanism has been replaced by "recovery models".


Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old October 9th, 2003, 03:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

I see...thanks Jeff.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Create backup folder & also backup files miracles Excel VBA 0 April 16th, 2007 02:28 AM
Backup scandalous Access 3 February 9th, 2007 01:19 PM
Backup help slesicki SQL Server 2005 2 December 28th, 2006 05:11 AM
What's the best way to backup? thomasks Visual Basic 2005 Basics 2 September 13th, 2006 03:36 PM
BAckUp sachindhillan Oracle 2 September 28th, 2003 07:32 AM





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