<?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: Truncating Transaction Logs in SQL 2008</title>
	<atom:link href="http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/</link>
	<description>a discussion of technology and software development</description>
	<lastBuildDate>Fri, 20 Jan 2012 13:25:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: MM</title>
		<link>http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/#comment-52</link>
		<dc:creator>MM</dc:creator>
		<pubDate>Fri, 09 Sep 2011 03:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.ofonesandzeros.com/?p=182#comment-52</guid>
		<description>Thank you so much.........
you made my day...</description>
		<content:encoded><![CDATA[<p>Thank you so much&#8230;&#8230;&#8230;<br />
you made my day&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pare</title>
		<link>http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/#comment-51</link>
		<dc:creator>Pare</dc:creator>
		<pubDate>Sun, 28 Aug 2011 06:04:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.ofonesandzeros.com/?p=182#comment-51</guid>
		<description>Great Man, thx</description>
		<content:encoded><![CDATA[<p>Great Man, thx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: juanMa</title>
		<link>http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/#comment-50</link>
		<dc:creator>juanMa</dc:creator>
		<pubDate>Fri, 24 Jun 2011 20:31:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.ofonesandzeros.com/?p=182#comment-50</guid>
		<description>Hey Bryan, here is my version I was working on when I stumbled upon your version (wasn&#039;t sure how to get the log names).  It&#039;s made for sql server 2005.  Also I don&#039;t like cursors so they&#039;re not here.  
------------------------------------------
declare @SQLString NVARCHAR(MAX), @dbName as nvarchar(255), @logName as nvarchar(255)
declare @dbList as table( dbName nvarchar(255),logName nvarchar(255), runStatus bit default 0)

--Populate table variable with all db names and all db log file names
insert into @dbList (dbName,logName)
SELECT a.name, b.name from sys.databases a join sys.master_files b on a.database_id = b.database_id 
where b.type = 1 AND a.name not in (&#039;master&#039;, &#039;model&#039;, &#039;msdb&#039;, &#039;tempdb&#039;,&#039;distribution&#039;) 
order by a.name
--Loop over all db 
while (exists(select * from @dbList where runStatus=0))
begin
	--Get first available database
	SELECT top 1  @dbName = dbName, @logName = logName from @dbList where runStatus = 0
	--Prepare sql statement here
	SET @SQLString = 
		N&#039; USE &#039; + quotename(@dbName) + N&#039; ; &#039; +
		N&#039; DBCC SHRINKFILE(&#039; + quotename(@logName) + &#039; , 1) ; &#039; +
		N&#039; BACKUP LOG &#039; + quotename(@dbName) +&#039; WITH TRUNCATE_ONLY ;&#039; +
		N&#039; DBCC SHRINKFILE(&#039; + quotename(@logName) + &#039; , 1) ;&#039;
	--Execute
	EXECUTE sp_executesql @SQLString
	--Flag used database
	update @dbList set runStatus = 1 where dbName = @dbName
end</description>
		<content:encoded><![CDATA[<p>Hey Bryan, here is my version I was working on when I stumbled upon your version (wasn&#8217;t sure how to get the log names).  It&#8217;s made for sql server 2005.  Also I don&#8217;t like cursors so they&#8217;re not here.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
declare @SQLString NVARCHAR(MAX), @dbName as nvarchar(255), @logName as nvarchar(255)<br />
declare @dbList as table( dbName nvarchar(255),logName nvarchar(255), runStatus bit default 0)</p>
<p>&#8211;Populate table variable with all db names and all db log file names<br />
insert into @dbList (dbName,logName)<br />
SELECT a.name, b.name from sys.databases a join sys.master_files b on a.database_id = b.database_id<br />
where b.type = 1 AND a.name not in (&#8216;master&#8217;, &#8216;model&#8217;, &#8216;msdb&#8217;, &#8216;tempdb&#8217;,'distribution&#8217;)<br />
order by a.name<br />
&#8211;Loop over all db<br />
while (exists(select * from @dbList where runStatus=0))<br />
begin<br />
	&#8211;Get first available database<br />
	SELECT top 1  @dbName = dbName, @logName = logName from @dbList where runStatus = 0<br />
	&#8211;Prepare sql statement here<br />
	SET @SQLString =<br />
		N&#8217; USE &#8216; + quotename(@dbName) + N&#8217; ; &#8216; +<br />
		N&#8217; DBCC SHRINKFILE(&#8216; + quotename(@logName) + &#8216; , 1) ; &#8216; +<br />
		N&#8217; BACKUP LOG &#8216; + quotename(@dbName) +&#8217; WITH TRUNCATE_ONLY ;&#8217; +<br />
		N&#8217; DBCC SHRINKFILE(&#8216; + quotename(@logName) + &#8216; , 1) ;&#8217;<br />
	&#8211;Execute<br />
	EXECUTE sp_executesql @SQLString<br />
	&#8211;Flag used database<br />
	update @dbList set runStatus = 1 where dbName = @dbName<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: juanMa</title>
		<link>http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/#comment-49</link>
		<dc:creator>juanMa</dc:creator>
		<pubDate>Fri, 24 Jun 2011 19:06:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.ofonesandzeros.com/?p=182#comment-49</guid>
		<description>Have you tried using the built in function quotename() for T-SQL?
It returns the input string a valid SQL Server delimited identifier. ie, with [ ]

Very useful script.</description>
		<content:encoded><![CDATA[<p>Have you tried using the built in function quotename() for T-SQL?<br />
It returns the input string a valid SQL Server delimited identifier. ie, with [ ]</p>
<p>Very useful script.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dileep</title>
		<link>http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/#comment-48</link>
		<dc:creator>Dileep</dc:creator>
		<pubDate>Thu, 23 Jun 2011 02:18:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.ofonesandzeros.com/?p=182#comment-48</guid>
		<description>That was seriously good.</description>
		<content:encoded><![CDATA[<p>That was seriously good.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernhard Marx</title>
		<link>http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/#comment-43</link>
		<dc:creator>Bernhard Marx</dc:creator>
		<pubDate>Sat, 12 Mar 2011 08:07:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.ofonesandzeros.com/?p=182#comment-43</guid>
		<description>Thanks a lot. This saved my &quot;life&quot;</description>
		<content:encoded><![CDATA[<p>Thanks a lot. This saved my &#8220;life&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bryan</title>
		<link>http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/#comment-42</link>
		<dc:creator>bryan</dc:creator>
		<pubDate>Fri, 28 Jan 2011 00:55:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.ofonesandzeros.com/?p=182#comment-42</guid>
		<description>Glad it was of use to you!</description>
		<content:encoded><![CDATA[<p>Glad it was of use to you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zehra Nasif</title>
		<link>http://www.ofonesandzeros.com/2010/01/29/truncating-transaction-logs-in-sql-2008/#comment-41</link>
		<dc:creator>Zehra Nasif</dc:creator>
		<pubDate>Thu, 27 Jan 2011 22:33:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.ofonesandzeros.com/?p=182#comment-41</guid>
		<description>Thank you so much; saved a lot of time and headache when I needed this script right away.</description>
		<content:encoded><![CDATA[<p>Thank you so much; saved a lot of time and headache when I needed this script right away.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic
Database Caching 1/4 queries in 0.008 seconds using disk: basic
Object Caching 299/303 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: dfcv747gi313t.cloudfront.net

Served from: www.ofonesandzeros.com @ 2012-02-05 13:17:31 -->
