Author |
Topic |
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2010-01-13 : 04:48:14
|
Hi i've used the following code to shrink the log fileUSE DatabaseNameGODBCC SHRINKFILE(<TransactionLogName>, 1)BACKUP LOG <DatabaseName> WITH TRUNCATE_ONLYDBCC SHRINKFILE(<TransactionLogName>, 1)GO But am still getting the full log file error the the log file is full |
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2010-01-13 : 05:43:18
|
If it's an emergency scenario : DBCC SHRINKFILE (logfile, truncateonly ) BACKUP LOG database name WITH TRUNCATE_ONLY otherwise , do not use this method for regular backups , file menagement. As ability to recover will be impairedJack Vamvas--------------------http://www.ITjobfeed.com |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-01-13 : 08:25:05
|
"But am still getting the full log file error the the log file is full"Is your Log file set to allow growth, or is it fixed size? That might be your problem.DBCC SHRINKFILE (logfile, truncateonly )BACKUP LOG database name WITH TRUNCATE_ONLY I would advocate also doing an immediate FULL backup after this - otherwise I think that TLog backups may not resume UNTIL the next FULL Backup? (and if they do resume they are probably not usable in the absence of a Full backup?) |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2010-01-13 : 10:38:13
|
Is there an old open transaction? Or replication?Post results ofDBCC OPENTRAN--Gail ShawSQL Server MVP |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2010-01-13 : 10:39:36
|
quote: Originally posted by jackvDBCC SHRINKFILE (logfile, truncateonly )
It may be worth noting that truncateonly is ignored when shrinking a log file. It's only a valid option for data files.--Gail ShawSQL Server MVP |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-01-13 : 10:59:14
|
Thanks, I was just quoting JackV and it was Jack's subsequent "BACKUP LOG database name WITH TRUNCATE_ONLY" that I was worried about |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2010-01-13 : 15:16:30
|
Sorry, I'll go edit who I quoted there.--Gail ShawSQL Server MVP |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2010-01-14 : 01:47:45
|
GilaMonster , thanks for clarifying . It should be: DBCC SHRINKFILE (logfile, 1 )BACKUP LOG database name WITH TRUNCATE_ONLY Jack Vamvas--------------------http://www.ITjobfeed.com |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2010-01-14 : 04:52:05
|
quote: Originally posted by jackv GilaMonster , thanks for clarifying . It should be: DBCC SHRINKFILE (logfile, 1 )
That's worse.Firstly, if you're going to truncate the log, makes sense to do it before the shrink, so that the shrink can reclaim some space.Second, the log should not be shrunk as small as possible. It should be shrunk to a reasonable size for the frequency of transactions and the log backup interval. Shrinking to 1 just ensures that there will be lots of autogrows in the immediate future.Oh, and it goes without saying, after truncating the log, take a full backup immediately to restart the log chain--Gail ShawSQL Server MVP |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2010-01-14 : 06:58:08
|
In theory, if you wanted to shrink it to the minimum size possible , you could use DBCC SHRINKFILE (logfile, 1 ). I'm making no assumptions about the nature of how the user is managing their environment - Jack Vamvas--------------------http://www.ITjobfeed.com |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2010-01-14 : 07:02:56
|
In theory, if you wanted to shrink it to the minimum size possible , you could use DBCC SHRINKFILE (logfile, 1 ). I'm making no assumptions about the nature of how the user is managing their environment - Jack Vamvas--------------------http://www.ITjobfeed.com |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2010-01-14 : 11:53:58
|
If you do shrink it down to a small number such as 1MB, ensure you autogrow at a decent size to avoid the VLF recovery issue. One of the DBAs here had a database take 9 days to recover at startup due to 80k VLFs. On medium-large databases, the autogrow should be set to 8GB according to Microsoft.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog"Let's begin with the premise that everything you've done up until this point is wrong." |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-01-14 : 12:07:15
|
Interesting Tara. What are VLFs, and if a lot of them are created can that be fixed after-the-fact? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
Kristen
Test
22859 Posts |
Posted - 2010-01-14 : 13:27:05
|
Thanks Tara.P.S. These things will keep me in Smoke and Mirrors for years, as a consultant. I do wonder if it really has to be like that though ... |
|
|
|