SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Best way to truncate a log in simple mode ?


Best way to truncate a log in simple mode ?

Author
Message
mjwlufc
mjwlufc
SSC-Enthusiastic
SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)

Group: General Forum Members
Points: 130 Visits: 43
Hi,

I have a 60Gb log file i need to truncate on a DB running in simple mode - what is the easiest way to do this ?

In 2005 I used to use

backup log dbname with truncate_only and then shrink the file in Enterprise manger but i believe this method has changed in 2008

tia,
Mike.
John Mitchell-245523
John Mitchell-245523
SSC-Dedicated
SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)

Group: General Forum Members
Points: 33743 Visits: 16649
The easiest way to do that is just to wait and the log will be automatically truncated for you. You shouldn't have to wait more than a minute for it to happen. If it doesn't happen automatically then there's some reason why log space can't be reused - this will not be resolved by truncating manually.

Why do you want to shrink the log file? Are you confident that it will never grow back to 60GB? If you're not, it's likely that you're wasting resources and causing fragmentation on your disk.

John
mjwlufc
mjwlufc
SSC-Enthusiastic
SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)

Group: General Forum Members
Points: 130 Visits: 43
It doesn't seem to be reducing in size just growing..

The only reason i noticed it is the DB it logs for is only 2Gb in size so appears rather huge in comparison.

We are not low on disk space so if you believe it has no detrimental affect on performance i'll just leave it...

Maybe wrongly i believed it was good practice to keeps logs at a reasonable size
John Mitchell-245523
John Mitchell-245523
SSC-Dedicated
SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)

Group: General Forum Members
Points: 33743 Visits: 16649
You certainly need to investigate why a database of that size has a log of that size. My point was only that if it won't truncate automatically, it won't truncate manually, either.

Use DBCC SQLPERF(LOGSPACE) to find out how much free space you have in your log file. This will give you an idea of whether you have a problem at this very moment. It may be that you have a long-running large transaction.

Please also read this article by Gail Shaw, which explains things better than I can:
http://www.sqlservercentral.com/articles/Transaction+Logs/72488/

John
anthony.green
anthony.green
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23694 Visits: 6519
These should provide some good reading on the topic of TX log management

Why is my transaction log full - http://www.sqlservercentral.com/articles/Transaction+Logs/72488/
Managing Transaction Logs - http://www.sqlservercentral.com/articles/Administration/64582/
Stairway to Transaction Log Management - http://www.sqlservercentral.com/stairway/73776/
Accidental DBA Guide - Chapter 8 - http://www.simple-talk.com/books/sql-books/troubleshooting-sql-server-a-guide-for-the-accidental-dba/



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


mjwlufc
mjwlufc
SSC-Enthusiastic
SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)

Group: General Forum Members
Points: 130 Visits: 43
Interestingly the %used was pretty high @ 92.6%

virtual 64481.87 92.59304
anthony.green
anthony.green
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23694 Visits: 6519
Something is activly using the log then.

The first link on why is my transaction log full should help to find out what is using so much log space.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Bobby Glover
Bobby Glover
SSC Eights!
SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)

Group: General Forum Members
Points: 817 Visits: 751
USE database_name
GO
DBCC SHRINKFILE(2,1)
BACKUP LOG database_name WITH TRUNCATE_ONLY
DBCC SHRINKFILE(2,1)


The above assume the logfile is file 2.

SP_helpdb databasename

Right click db,TASKS,SHRINK change to log and see how much space is actually being used.

Then click cancel.
Bobby Glover
Bobby Glover
SSC Eights!
SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)SSC Eights! (817 reputation)

Group: General Forum Members
Points: 817 Visits: 751
FOR 2008

USE 2008db;
GO
DBCC SHRINKFILE (<logical_logfilename>,5);
GO

For sql 2008
5- size you want to shrink to.

<logical_logfilename> run sp_helpdb.
mjwlufc
mjwlufc
SSC-Enthusiastic
SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)SSC-Enthusiastic (130 reputation)

Group: General Forum Members
Points: 130 Visits: 43
DBCC OPENTRAN returns no clues

No active open transactions.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search