<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SQL Server 2005 &#8211; How to shrink the truncated log file.</title>
	<atom:link href="http://blog.joggee.com/index.php?feed=rss2&#038;p=65" rel="self" type="application/rss+xml" />
	<link>http://blog.joggee.com/?p=65</link>
	<description>ASP.NET,VB.NET,C#.NET,SQL SERVER,DATABASE,XML,WEBSERVICES,JAVA,SOFTWARE,PROGRAMMING,MANAGEMENT</description>
	<lastBuildDate>Wed, 03 Feb 2010 02:47:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: sandra407</title>
		<link>http://blog.joggee.com/?p=65&#038;cpage=1#comment-623</link>
		<dc:creator>sandra407</dc:creator>
		<pubDate>Wed, 09 Sep 2009 16:06:26 +0000</pubDate>
		<guid isPermaLink="false">http://codeproject.wordpress.com/2007/09/25/sql-server-2005-how-to-shrink-the-truncated-log-file/#comment-623</guid>
		<description>Hi! I was surfing and found your blog post... nice! I love your blog.  :) Cheers! Sandra. R.</description>
		<content:encoded><![CDATA[<p>Hi! I was surfing and found your blog post&#8230; nice! I love your blog.  <img src='http://blog.joggee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Cheers! Sandra. R.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://blog.joggee.com/?p=65&#038;cpage=1#comment-275</link>
		<dc:creator>James</dc:creator>
		<pubDate>Fri, 19 Sep 2008 01:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://codeproject.wordpress.com/2007/09/25/sql-server-2005-how-to-shrink-the-truncated-log-file/#comment-275</guid>
		<description>Hi, I found your blog on this new directory of WordPress Blogs at blackhatbootcamp.com/listofwordpressblogs.  I dont know how your blog came up, must have been a typo, i duno.  Anyways, I just clicked it and here I am.  Your blog looks good.  Have a nice day.  James.</description>
		<content:encoded><![CDATA[<p>Hi, I found your blog on this new directory of WordPress Blogs at blackhatbootcamp.com/listofwordpressblogs.  I dont know how your blog came up, must have been a typo, i duno.  Anyways, I just clicked it and here I am.  Your blog looks good.  Have a nice day.  James.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron Barone</title>
		<link>http://blog.joggee.com/?p=65&#038;cpage=1#comment-253</link>
		<dc:creator>Ron Barone</dc:creator>
		<pubDate>Mon, 08 Sep 2008 01:10:25 +0000</pubDate>
		<guid isPermaLink="false">http://codeproject.wordpress.com/2007/09/25/sql-server-2005-how-to-shrink-the-truncated-log-file/#comment-253</guid>
		<description>I use this, and it works great on 2005.  I cant remember where I got this code snippet from but whomever wrote it, thanks!


   SET NOCOUNT ON
   DECLARE @LogicalFileName sysname,
           @MaxMinutes INT,
           @NewSize INT
   -- *** MAKE SURE TO CHANGE THE NEXT 4 LINES WITH YOUR CRITERIA. ***
   USE     [YourDatabase]              -- This is the name of the database
                                  -- for which the log will be shrunk.
   SELECT  @LogicalFileName = &#039;YourDatabase_Log&#039;,  -- Use sp_helpfile to 
      -- identify the logical file 
      -- name that you want to shrink.
           @MaxMinutes = 1,      -- Limit on time allowed to wrap log.
           @NewSize    = 50       -- in MB

   -- Setup / initialize
   DECLARE @OriginalSize int
   SELECT @OriginalSize = size -- in 8K pages
     FROM sysfiles
     WHERE name = @LogicalFileName
   SELECT &#039;Original Size of &#039; + db_name() + &#039; LOG is &#039; + 
           CONVERT(VARCHAR(30),@OriginalSize) + &#039; 8K pages or &#039; + 
           CONVERT(VARCHAR(30),(@OriginalSize*8/1024)) + &#039;MB&#039;
     FROM sysfiles
     WHERE name = @LogicalFileName

   CREATE TABLE DummyTrans
     (DummyColumn char (8000) not null)

   -- Wrap log and truncate it.
   DECLARE @Counter   INT,
           @StartTime DATETIME,
           @TruncLog  VARCHAR(255)
   SELECT  @StartTime = GETDATE(),
           @TruncLog = &#039;BACKUP LOG [&#039;+ db_name() + &#039;] WITH TRUNCATE_ONLY&#039;
   -- Try an initial shrink.
   DBCC SHRINKFILE (@LogicalFileName, @NewSize)

   EXEC (@TruncLog)

   -- Wrap the log if necessary.
   WHILE     @MaxMinutes &gt; DATEDIFF (mi, @StartTime, GETDATE()) -- time has not expired
         AND @OriginalSize = (SELECT size FROM sysfiles WHERE name = @LogicalFileName)  -- the log has not shrunk    
         AND (@OriginalSize * 8 /1024) &gt; @NewSize  -- The value passed in for new size is smaller than the current size.
     BEGIN -- Outer loop.
       SELECT @Counter = 0
       WHILE  ((@Counter &lt; @OriginalSize / 16) AND (@Counter &lt; 50000))
         BEGIN -- update
           INSERT DummyTrans VALUES (&#039;Fill Log&#039;)  -- Because it is a char field it inserts 8000 bytes.
           DELETE DummyTrans
           SELECT @Counter = @Counter + 1
         END   -- update
       EXEC (@TruncLog)  -- See if a trunc of the log shrinks it.
     END   -- outer loop
   SELECT &#039;Final Size of &#039; + db_name() + &#039; LOG is &#039; +
           CONVERT(VARCHAR(30),size) + &#039; 8K pages or &#039; + 
           CONVERT(VARCHAR(30),(size*8/1024)) + &#039;MB&#039;
     FROM sysfiles 
     WHERE name = @LogicalFileName
   DROP TABLE DummyTrans
   PRINT &#039;*** Perform a full database backup ***&#039;
   SET NOCOUNT OFF</description>
		<content:encoded><![CDATA[<p>I use this, and it works great on 2005.  I cant remember where I got this code snippet from but whomever wrote it, thanks!</p>
<p>   SET NOCOUNT ON<br />
   DECLARE @LogicalFileName sysname,<br />
           @MaxMinutes INT,<br />
           @NewSize INT<br />
   &#8212; *** MAKE SURE TO CHANGE THE NEXT 4 LINES WITH YOUR CRITERIA. ***<br />
   USE     [YourDatabase]              &#8212; This is the name of the database<br />
                                  &#8212; for which the log will be shrunk.<br />
   SELECT  @LogicalFileName = &#8216;YourDatabase_Log&#8217;,  &#8212; Use sp_helpfile to<br />
      &#8212; identify the logical file<br />
      &#8212; name that you want to shrink.<br />
           @MaxMinutes = 1,      &#8212; Limit on time allowed to wrap log.<br />
           @NewSize    = 50       &#8212; in MB</p>
<p>   &#8212; Setup / initialize<br />
   DECLARE @OriginalSize int<br />
   SELECT @OriginalSize = size &#8212; in 8K pages<br />
     FROM sysfiles<br />
     WHERE name = @LogicalFileName<br />
   SELECT &#8216;Original Size of &#8216; + db_name() + &#8216; LOG is &#8216; +<br />
           CONVERT(VARCHAR(30),@OriginalSize) + &#8216; 8K pages or &#8216; +<br />
           CONVERT(VARCHAR(30),(@OriginalSize*8/1024)) + &#8216;MB&#8217;<br />
     FROM sysfiles<br />
     WHERE name = @LogicalFileName</p>
<p>   CREATE TABLE DummyTrans<br />
     (DummyColumn char (8000) not null)</p>
<p>   &#8212; Wrap log and truncate it.<br />
   DECLARE @Counter   INT,<br />
           @StartTime DATETIME,<br />
           @TruncLog  VARCHAR(255)<br />
   SELECT  @StartTime = GETDATE(),<br />
           @TruncLog = &#8216;BACKUP LOG ['+ db_name() + '] WITH TRUNCATE_ONLY&#8217;<br />
   &#8212; Try an initial shrink.<br />
   DBCC SHRINKFILE (@LogicalFileName, @NewSize)</p>
<p>   EXEC (@TruncLog)</p>
<p>   &#8212; Wrap the log if necessary.<br />
   WHILE     @MaxMinutes &gt; DATEDIFF (mi, @StartTime, GETDATE()) &#8212; time has not expired<br />
         AND @OriginalSize = (SELECT size FROM sysfiles WHERE name = @LogicalFileName)  &#8212; the log has not shrunk<br />
         AND (@OriginalSize * 8 /1024) &gt; @NewSize  &#8212; The value passed in for new size is smaller than the current size.<br />
     BEGIN &#8212; Outer loop.<br />
       SELECT @Counter = 0<br />
       WHILE  ((@Counter &lt; @OriginalSize / 16) AND (@Counter &lt; 50000))<br />
         BEGIN &#8212; update<br />
           INSERT DummyTrans VALUES (&#8217;Fill Log&#8217;)  &#8212; Because it is a char field it inserts 8000 bytes.<br />
           DELETE DummyTrans<br />
           SELECT @Counter = @Counter + 1<br />
         END   &#8212; update<br />
       EXEC (@TruncLog)  &#8212; See if a trunc of the log shrinks it.<br />
     END   &#8212; outer loop<br />
   SELECT &#8216;Final Size of &#8216; + db_name() + &#8216; LOG is &#8216; +<br />
           CONVERT(VARCHAR(30),size) + &#8216; 8K pages or &#8216; +<br />
           CONVERT(VARCHAR(30),(size*8/1024)) + &#8216;MB&#8217;<br />
     FROM sysfiles<br />
     WHERE name = @LogicalFileName<br />
   DROP TABLE DummyTrans<br />
   PRINT &#8216;*** Perform a full database backup ***&#8217;<br />
   SET NOCOUNT OFF</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: codeproject</title>
		<link>http://blog.joggee.com/?p=65&#038;cpage=1#comment-38</link>
		<dc:creator>codeproject</dc:creator>
		<pubDate>Tue, 13 Nov 2007 09:05:45 +0000</pubDate>
		<guid isPermaLink="false">http://codeproject.wordpress.com/2007/09/25/sql-server-2005-how-to-shrink-the-truncated-log-file/#comment-38</guid>
		<description>Thanks for your comments , a + b will always add the things.

Same way we have some expression BACKUP LOG  WITH TRUNCATE_ONLY
which are builtin, so we are using them , I did the same.

Rana</description>
		<content:encoded><![CDATA[<p>Thanks for your comments , a + b will always add the things.</p>
<p>Same way we have some expression BACKUP LOG  WITH TRUNCATE_ONLY<br />
which are builtin, so we are using them , I did the same.</p>
<p>Rana</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joe</title>
		<link>http://blog.joggee.com/?p=65&#038;cpage=1#comment-37</link>
		<dc:creator>joe</dc:creator>
		<pubDate>Mon, 12 Nov 2007 16:31:44 +0000</pubDate>
		<guid isPermaLink="false">http://codeproject.wordpress.com/2007/09/25/sql-server-2005-how-to-shrink-the-truncated-log-file/#comment-37</guid>
		<description>Horrible. All you did is copy something from BOL, fowl it up with typos, and post it. I feel sorry for your employer.</description>
		<content:encoded><![CDATA[<p>Horrible. All you did is copy something from BOL, fowl it up with typos, and post it. I feel sorry for your employer.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
