Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Best way to truncate a log in simple mode ? Expand / Collapse
Author
Message
Posted Thursday, August 30, 2012 2:53 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, January 29, 2013 4:07 AM
Points: 26, 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.
Post #1352058
Posted Thursday, August 30, 2012 3:08 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 8:58 AM
Points: 5,077, Visits: 8,918
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
Post #1352063
Posted Thursday, August 30, 2012 3:17 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, January 29, 2013 4:07 AM
Points: 26, 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

Post #1352066
Posted Thursday, August 30, 2012 3:24 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 8:58 AM
Points: 5,077, Visits: 8,918
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
Post #1352069
Posted Thursday, August 30, 2012 3:27 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, August 28, 2013 2:37 AM
Points: 5,075, Visits: 4,834
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
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

Post #1352070
Posted Thursday, August 30, 2012 3:32 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, January 29, 2013 4:07 AM
Points: 26, Visits: 43
Interestingly the %used was pretty high @ 92.6%

virtual 64481.87 92.59304
Post #1352071
Posted Thursday, August 30, 2012 3:35 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, August 28, 2013 2:37 AM
Points: 5,075, Visits: 4,834
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
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

Post #1352072
Posted Thursday, August 30, 2012 3:36 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, August 09, 2013 8:19 AM
Points: 179, 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.

Post #1352074
Posted Thursday, August 30, 2012 3:40 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, August 09, 2013 8:19 AM
Points: 179, 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.


Post #1352076
Posted Thursday, August 30, 2012 3:45 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, January 29, 2013 4:07 AM
Points: 26, Visits: 43
DBCC OPENTRAN returns no clues

No active open transactions.
Post #1352079
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse