<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQL Slayer &#187; Cleanup</title>
	<atom:link href="http://www.sqlslayer.com/wp/tag/cleanup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sqlslayer.com/wp</link>
	<description>Making SQL do what we want it to do.</description>
	<lastBuildDate>Mon, 12 Dec 2011 13:53:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Work-around for 2005 Maintenance Plan bug</title>
		<link>http://www.sqlslayer.com/wp/2009/10/06/work-around-for-2005-maintenance-plan-bug/</link>
		<comments>http://www.sqlslayer.com/wp/2009/10/06/work-around-for-2005-maintenance-plan-bug/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 19:47:28 +0000</pubDate>
		<dc:creator>mlakarj</dc:creator>
				<category><![CDATA[Backups]]></category>
		<category><![CDATA[Cleanup]]></category>
		<category><![CDATA[Maintenance Plans]]></category>
		<category><![CDATA[SQL SERVER 2005]]></category>

		<guid isPermaLink="false">http://www.sqlslayer.com/wp/?p=77</guid>
		<description><![CDATA[<p>In working with SQL 2005 Maintenance Plan backup cleanup tasks, a frustrating bug was found.  It seems that when the ability to select &#8220;hours&#8221; as a time criterion was added in SP2, the door was opened for misinterpretation of time units.  For example, you can, in your local Management Studio, set the Plan to delete [...]]]></description>
			<content:encoded><![CDATA[<p>In working with SQL 2005 Maintenance Plan backup cleanup tasks, a frustrating bug was found.  It seems that when the ability to select &#8220;hours&#8221; as a time criterion was added in SP2, the door was opened for misinterpretation of time units.  For example, you can, in your local Management Studio, set the Plan to delete files greater that 4 <strong>days </strong>old, and when run on the server the Plan will delete files only greater than 4 <strong>WEEKS </strong>old.  This was the full mapping I found:</p>
<p> <strong>SET                  ACTUAL<br />
</strong>Hours   -&gt;         Days<br />
Days    -&gt;         Weeks<br />
Weeks  -&gt;         Months<br />
Months -&gt;         Years<br />
Years    -&gt;         Years</p>
<p>I don’t know yet if this is fixed in 2008.  For 2005 at least, I suggest refraining from using the built-in &#8220;Maintenance Cleanup Tasks&#8221; in Maintenance Plans, and instead use a T-SQL Statement task with the snippet below.  This will truly delete greater than 4 days.  Set your time criteria however you like.</p>
<p> <code></p>
<blockquote><p>
DECLARE @DateOlderThan datetime<br />
SET @DateOlderThan = DATEADD(day,-4,GETDATE())</p>
<p>EXEC master.dbo.xp_delete_file<br />
 0 -- delete files<br />
,N'H:\SQLBackup\INST3' --full path to the main directory<br />
,N'bak'-- file extension<br />
,@DateOlderThan-- delete files created before this timestamp<br />
,1-- Including first-level sub
</p></blockquote>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sqlslayer.com/wp/2009/10/06/work-around-for-2005-maintenance-plan-bug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

