 




<?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 Server with Mr. Denny &#187; Recovery</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/sql-server/tag/recovery/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/sql-server</link>
	<description></description>
	<lastBuildDate>Fri, 17 May 2013 17:04:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Backup Databases on Creation</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/backup-databases-on-creation/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/backup-databases-on-creation/#comments</comments>
		<pubDate>Sat, 17 Nov 2012 14:00:56 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Backup & recovery]]></category>
		<category><![CDATA[BACKUP DATABASE]]></category>
		<category><![CDATA[CREATE TRIGGER]]></category>
		<category><![CDATA[Data Loss]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[DDL Trigger]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008 R2]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[T/SQL]]></category>
		<category><![CDATA[Transactions]]></category>
		<category><![CDATA[Trigger]]></category>
		<category><![CDATA[xp_create_subdir]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2194</guid>
		<description><![CDATA[One of the companies which I work with has the occasion to create new databases when they do releases of their software.  Normally this isn&#8217;t a problem, except that they are setup to use maintenance plans to handle the backup and pruning of their transaction logs.  As all the new databases are created in the [...]]]></description>
				<content:encoded><![CDATA[<p>One of the companies which I work with has the occasion to create new databases when they do releases of their software.  Normally this isn&#8217;t a problem, except that they are setup to use maintenance plans to handle the backup and pruning of their transaction logs.  As all the new databases are created in the full recovery model this can end up causing some problems for them as within 12 minutes they start getting emails saying that the transaction log backup job has failed.  And these emails will keep coming in, possibly for hours until the full backup job kicks in later that night.</p>
<p>To solve this problem, I added a DDL trigger to the server which will cause the new database to be backed up as soon as the database is created.  The trigger itself is rather simple.  Most of the trigger is setting variables.  Then I make sure that the database isn&#8217;t a database snapshot, as database snapshots can&#8217;t be backed up.  If it isn&#8217;t a snapshot we continue with everything else.</p>
<p>Then I create a subfolder for the backups to be put into (the backups for each database go into their own folder, so as this is a new database the folder needs to be created).  Then I commit the transaction, as database backups can&#8217;t be taken within a transaction.  Then we do the actual database backup.  I then throw a message to the end user using the RAISERROR statement telling them that they can ignore the other error that they are going to get about the transaction being closed before the trigger was complete.  This is just an annoyance of my needing to commit the transaction before taking the backup.  Sure I could have setup a job which takes the backup and emails if there was a failure, but that just seems to complex for something so simple.  The code for my trigger is below.</p>
<blockquote><p>CREATE TRIGGER BackupNewDatabase<br />
ON ALL SERVER<br />
FOR CREATE_DATABASE<br />
AS<br />
declare @database sysname, @event_data XML = EVENTDATA(), @folder nvarchar(4000), @file nvarchar(4000)</p>
<p>SET @database = @event_data.value(&#8216;(/EVENT_INSTANCE/DatabaseName)[1]&#8216;, &#8216;sysname&#8217;)</p>
<p>set @folder = &#8216;X:\Backups\&#8217; + @database</p>
<p>set @file = @folder + &#8216;\&#8217; + @database + &#8216;.bak&#8217;</p>
<p>if exists (select * from sys.databases where name = @database and source_database_id is null)<br />
BEGIN<br />
EXEC master.dbo.xp_create_subdir @folder</p>
<p>COMMIT</p>
<p>BACKUP DATABASE @database to disk=@file</p>
<p>raiserror( &#8216;You can ignore the error message which says that the transaction ended within the trigger.&#8217;, 16,1)<br />
END<br />
GO</p></blockquote>
<p>Hopefully you find this solution helpful if you get into a situation like this,<br />
Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/backup-databases-on-creation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lugging fuel up stairs shouldn&#8217;t have been needed</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/lugging-fuel-up-stairs-shouldnt-have-been-needed/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/lugging-fuel-up-stairs-shouldnt-have-been-needed/#comments</comments>
		<pubDate>Thu, 01 Nov 2012 18:17:29 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Data Loss]]></category>
		<category><![CDATA[DataCenter]]></category>
		<category><![CDATA[Distaster Recovery]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=2433</guid>
		<description><![CDATA[While I applaud the hard work and ingenuity of the sysadmins who works through the days after hurricane Sandy to keep the generators running, one thing kept coming to my mind.  Why was this needed? I&#8217;ve moved lots of companies into data centers before, and each time I&#8217;ve done so it has included a site [...]]]></description>
				<content:encoded><![CDATA[<p>While I applaud the <a href="http://mobile.theverge.com/2012/10/31/3581916/new-york-hurricane-sandy-stackexchange-squarespace-gawker">hard work and ingenuity of the sysadmins</a> who works through the days after hurricane Sandy to keep the generators running, one thing kept coming to my mind.  Why was this needed?</p>
<p>I&#8217;ve moved lots of companies into data centers before, and each time I&#8217;ve done so it has included a site visit during to RFP process to check on things like cooling, generator, site configuration, etc.  During these site visits I stick my head through every door that the sales guy and the engineer who are doing the tour will open.  If they won&#8217;t open a door for me they better have a damn good reason to not show me what&#8217;s in there.</p>
<p>If I went to do a site visit at a facility that was located just at sea level just a few blocks from the ocean, they&#8217;d better have some pretty impressive plans for how they are going to handle flooding.  If the answer was &#8220;we&#8217;ve never had a problem with flooding&#8221; or something similar they&#8217;d be off my list as they haven&#8217;t done their due diligence to insure that the site will be online during the worst emergencies possible.</p>
<p>Now before you start telling me that I&#8217;ve got no idea what I&#8217;m talking about, and that data centers in the North East have different problems from data centers in the South West.  I actually do as I&#8217;ve moved companies into data centers on both coasts.  Most recently I moved the data center for <a href="http://www.phreesia.com">Phreesia </a>from a managed service facility in Texas to a colo in New Jersey.  As a part of this move we looked at a number of facilities in the New York / New Jersey area.  Many of the New York City data centers were eliminated due to cost, or being just to close to the water as we didn&#8217;t want to deal with situations like this exact one.</p>
<p>The data center we settled on is in New Jersey about a 30-40 minute drive from the Phreesia office (once you get out of New York City).  While the data center is near a river, the river is a little over a mile away.  The data center itself is on a slope with a  cinder block wall on the outer edge which will divert water away in the event of a river overflow (it also protects the facility from someone driving a car or truck into the facility).  The generators and fuel pumps are all mounted on raised feet (not very tall, but tall enough) so that they keep running in the event of a flood.  The cables from the generators to the building have all been buried under the ground so that tree branches which are torn loose during the hurricane can&#8217;t cut those cables.</p>
<p>Our diligence in selecting a data center paid off.  While the folks mentioned in that article were dragging buckets of fuel up 17 floors worth of stairs the team at Phreesia just sat back and rode out the storm with their families.  The sites didn&#8217;t go down and the team didn&#8217;t have to rush into a very hazardous situation. The team was able to focus on their families and neighbors without having to worry about the systems.  Those of us that aren&#8217;t in the New York area monitored the systems remotely and founds that everything was running perfectly normally just on generator power instead of city power.</p>
<p>This entire event just shows that when doing data center evaluations the worst possible case situation needs to be planned for and expected.  If they aren&#8217;t they are going to come back and bite you.  Especially in todays world of storms which are ever increasing in destructive power.</p>
<p>If you are in a facility which has risks such as fuel pumps which are below sea level (they are in the basement and the road is at sea level) then a second data center becomes very important very quickly.  This became very clear during this hurricane when some very large important websites went offline because they didn&#8217;t have that DR facility that they could fail over to, unlike sites like <a href="http://www.stackoverflow.com">StackOverflow</a> (and <a href="http://www.serverfault.com">ServerFault </a>and the Stack Exchange network).</p>
<p>If you are at risk now is an excellent time to sit down with management and go over all the &#8220;what ifs&#8221; of your current hosting solution and think about the cost of a DR site along with the cost of not having one.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/lugging-fuel-up-stairs-shouldnt-have-been-needed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Back To Basics: Why isn&#8217;t maintenace automatic?</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/back-to-basics-why-isnt-maintenace-automatic/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/back-to-basics-why-isnt-maintenace-automatic/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 14:00:13 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Back To Basics]]></category>
		<category><![CDATA[Backup & recovery]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/back-to-basics-why-isnt-maintenace-automatic/</guid>
		<description><![CDATA[One of the questions which I see pop up from time to time (especially when I used to work for a VAR that wrote software for small businesses) is why doesn&#8217;t SQL Server do the maintenance automatically?  Things like checking for corruption (DBCC CHECKDB), index defragmentation, backups, etc. The reason for this is pretty basic.  [...]]]></description>
				<content:encoded><![CDATA[<p>One of the questions which I see pop up from time to time (especially when I used to work for a VAR that wrote software for small businesses) is why doesn&#8217;t SQL Server do the maintenance automatically?  Things like checking for corruption (DBCC CHECKDB), index defragmentation, backups, etc.</p>
<p>The reason for this is pretty basic.  How is the SQL Server supposed to know what settings to use, or how often to do those things?  Every database needs to have the indexes rebuild at a different interval.  There are a variety of recovery options which would change the backup policy for a database.  Not to mention that to properly build backup settings the SQL Server would need to know things like your RPO (Recovery Point Objective aka. how much data are you willing to loose in the event of a major failure).  Without a way to tell the SQL Server these sorts of things the SQL Server wouldn&#8217;t be able to properly maintain your environment.</p>
<p>So there&#8217;s the why.</p>
<p>Denny</p>
<p style="text-align: center"><a href="http://sqlexcursions.com/napa-2011-sign-up"><img class="aligncenter size-full wp-image-1838" src="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2011/11/2012-napa-banner-plus-sql-denali1.jpg" alt="" width="500" height="61" /></a></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/back-to-basics-why-isnt-maintenace-automatic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What changing the recovery mode of your vCenter database really means</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/what-changing-the-recovery-mode-of-your-vcenter-database-really-means/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/what-changing-the-recovery-mode-of-your-vcenter-database-really-means/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 14:00:25 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Recovery]]></category>
		<category><![CDATA[vCenter]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/what-changing-the-recovery-mode-of-your-vcenter-database-really-means/</guid>
		<description><![CDATA[Apparently one of the things that VMware&#8217;s support department will often recommend that people do is to change the recovery mode of the vCenter database within SQL Server from FULL to SIMPLE recovery because it will magically make a lot of disk problems go away.  While this is true, your disk space issues on the [...]]]></description>
				<content:encoded><![CDATA[<p>Apparently one of the things that VMware&#8217;s support department will often recommend that people do is to change the recovery mode of the vCenter database within SQL Server from FULL to SIMPLE recovery because it will magically make a lot of disk problems go away.  While this is true, your disk space issues on the vCenter database will go away at this point, this isn&#8217;t magic and you have have just lost some functionally that you weren&#8217;t expecting to loose.</p>
<p>The big thing that you loose when doing this is that you can no longer restore the SQL Server database to a specific point in time if you have a system failure.  If you don&#8217;t need the ability to restore so a specific point in time, and restoring to your latest full or differential backup that you have (you do know that you need to backup the vCenter databases right?) then changing the recovery mode from FULL to SIMPLE is just fine.  However if you do need that ability (and I would recommend that you have that ability so that if the vCenter server fails or someone deletes data you can get back as much trending data as possible) then you will want to leave the recovery mode as FULL, but instead setup transaction log backups (hopefully you have a DBA or a <a href="http://www.mrdenny.com/">database consultant</a> that can help you with this) so that they run every few minutes (I typically recommend every 10-15 minutes).  Just keep in mind that when selecting how often they should run in the event of a server failure you may loose up to that amount of data from the database.  So if you aren&#8217;t aloud to loose more than 10 minutes worth of data, don&#8217;t backup the log every 15 minutes, back it up every 10, or maybe every 8 just to be safe.  Make sure that you get in writing from your management that this is the config that they want so if you get yelled at you are covered.</p>
<p>If you haven&#8217;t ever backed up the transaction log your disk is probably pretty full (or totally full).  In this case you will want to shrink the database just once.  But before you do you need to know what size you should shrink it to.  This can be much easier if a DBA does it, but I&#8217;ve got faith in you to not screw it up.</p>
<p>First connect to the SQL Server using Management Studio.  Take a backup of the transaction log to disk by right clicking on the database, selecting Tasks from the context menu then selecting Backup from the pop out menu.  Select transaction log backup, set a file to backup the log to (you&#8217;ll need a lot of disk space for this) and make sure that there&#8217;s only one file listed in the file list then start the backup.  This will probably take a while.</p>
<p>If you don&#8217;t care about loosing the log for now change the database from full to simple recovery and back.  Do this by running this script.</p>
<pre class="brush: sql; title: ; notranslate">
ALTER DATABASE vcdb
SET RECOVERY SIMPLE
GO
ALTER DATABASE vcdb
SET RECOVERY FULL
GO</pre>
<p>Now do a full backup as shown above (just do a full database backup instead of a transaction log backup).</p>
<p>Now with everything running as normal wait for how ever long it&#8217;ll be between transaction log backups.  Then connect to the SQL Server in SQL Server Management Studio.  Right click on the vCenter database (vcdb) and select Reports from the context menu, then &#8220;Disk Usage&#8221; from the list of reports.  At the top it&#8217;ll give you the size of the transaction log in MB, and the graph on the right will show you a percentage breakdown of how full the transaction log file is.  Take the Used percentage and double it.  Now take that percentage and multiple it by the size of the transaction log.  That&#8217;s the minimum size you should set your transaction log for.  Personally I would round up to the 8 gig size above that size.  If you need 150 Megs of log space, set the log for 8 Gigs in size.  If you need 10 Gigs of log space, let the log for 16 Gigs of space.  A little extra space used is fine, it is better for performance of the database if we don&#8217;t need to grow this transaction log.  You can shrink the transaction log by using the DBCC SHRINKFILE statement as shown.</p>
<pre class="brush: sql; title: ; notranslate">DBCC SHRINKFILE ('vbdc_log', 8388608)</pre>
<p>Keep in mind that the number, in this case 8 Gigs, is passed in in megs.  Do NOT for any reason create any sort of scheduled task to regularly shrink any database file.  This will do nothing good and will cause performance problems of its own.  If anyone has told you to setup a job which shrinks the database file regularly they are WRONG.</p>
<p>Denny</p>
<div class="mceTemp">
<dl>
<dt><a href="http://www.sqlserverdays.be"><img class="size-full wp-image-1756" src="http://cdn.ttgtmedia.com/ITKE/uploads/blogs.dir/20/files/2011/09/sqlserverdays2011.gif" alt="SQL Server Days 2011" width="500" height="61" /></a></dt>
</dl>
</div>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/what-changing-the-recovery-mode-of-your-vcenter-database-really-means/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transaction Log files are not safe to delete</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/transaction-log-files-are-not-safe-to-delete/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/transaction-log-files-are-not-safe-to-delete/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 11:00:20 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Recovery]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/?p=763</guid>
		<description><![CDATA[All to often I see people online saying that they detach a database then delete the log file to shrink it.  This is a very dangerous operation which can leave you with a corrupt database that you can&#8217;t do anything with. While you can normally attach a database without the log file, it doesn&#8217;t always [...]]]></description>
				<content:encoded><![CDATA[<p>All to often I see people online saying that they detach a database then delete the log file to shrink it.  This is a very dangerous operation which can leave you with a corrupt database that you can&#8217;t do anything with.<span id="more-763"></span></p>
<p>While you can normally attach a database without the log file, it doesn&#8217;t always work.  Sometimes SQL Server won&#8217;t be able to recover from this and create a new log file and you&#8217;l have lost the database.</p>
<p>If your database is growing and has gotten very large, then you&#8217;ll want to change the recorvery mode from FULL to SIMPLE.  This will help keep the transaction log file small, and is perfectly safe to do.  The only thing you will loose is the ability to do point in time restores of the transaction log.  However point in time restores are only available if you backup the transaction log (which would have prevented the log from growing out of control to begin with).</p>
<p>The reason that many people do this, is that the name of the file is misleading.  Normally logs are very safe to delete, however the transaction log isn&#8217;t your normal log file.  A transaction log keeps a record of every change to the database, along with the before and after values.  All changes are written to the transaction log before they are commited to the database itself so that if the server fails the database is left in a consistant state.</p>
<p>If your log file has simply gotten huge, and you need to make it smaller, you can use the DBCC SHRINKFILE command to shrink the log file to a smaller size.  This shouldn&#8217;t be done on a regular basis.  If you are doing this on a regular basis leave the file large it&#8217;s at the size it needs to be or change the database recovery to SIMPLE.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/transaction-log-files-are-not-safe-to-delete/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to setup a server to read log files nightly.</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/how-to-setup-a-server-to-read-log-files-nightly/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/how-to-setup-a-server-to-read-log-files-nightly/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 11:00:12 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Backup & recovery]]></category>
		<category><![CDATA[KILL]]></category>
		<category><![CDATA[Log Shipping]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[RESTORE LOG]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[xp_delete_file]]></category>
		<category><![CDATA[xp_dirtree]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/how-to-setup-a-server-to-read-log-files-nightly/</guid>
		<description><![CDATA[So you&#8217;ve been tasked with setting up a quick and dirty reporting server.  The goal is to restore the log files from the production server to the reporting server nightly.  The backups are simple, use the SQL Maintenance plan to backup the logs, and then copy them to the remote machine.  But how do you [...]]]></description>
				<content:encoded><![CDATA[<p>So you&#8217;ve been tasked with setting up a quick and dirty reporting server.  The goal is to restore the log files from the production server to the reporting server nightly.</p>
<p> The backups are simple, use the SQL Maintenance plan to backup the logs, and then copy them to the remote machine.  But how do you restore the logs to the reporting server nightly.</p>
<p> Well I&#8217;ve got a two step SQL job which should help you out.</p>
<p>Step 1 kills all current sessions in the database, and step 2 does the actual restores.</p>
<p>The code for step 1 is: </p>
<p><code>declare @spid varchar(20)<br />
declare cur CURSOR FOR<br />
select spid<br />
from sys.sysprocesses<br />
where dbid = db_id('Your Database Name Here') /*&lt;---Put your database name here*/<br />
and spid &gt; 50<br />
open cur<br />
fetch next from cur into @spid<br />
while @@FETCH_STATUS = 0<br />
BEGIN<br />
exec ('kill ' + @spid)<br />
fetch next from cur into @spid<br />
END<br />
close cur<br />
deallocate cur</code></p>
<p>The code for step 2 is:</p>
<p><code>create table #Files<br />
(FileName nvarchar(4000),<br />
Depth int,<br />
IsFile bit)</code><code>insert into #Files<br />
exec xp_dirtree 'd:\', 1, 1</p>
<p>delete from #Files<br />
where IsFile = 0</p>
<p>declare @FileName nvarchar(4000)<br />
declare cur CURSOR FOR SELECT FileName from #Files<br />
open cur<br />
fetch next from cur into @FileName<br />
WHILE @@FETCH_STATUS = 0<br />
BEGIN<br />
SET @FileName = 'D:\Path\To\Your\Log\Backups\' + @FileName<br />
RESTORE LOG YourDatabaseNameHere FROM <a href="mailto:DISK=@FileName">DISK=@FileName</a> WITH STANDBY='D:\Path\To\Your\StandBy\File.standby'<br />
IF @@ERROR &lt;&gt; 0<br />
exec xp_delete_file @FileName<br />
fetch next from cur into @FileName<br />
END<br />
close cur<br />
deallocate cur</p>
<p></code>I hope this makes your process easier. Now this code only works on SQL Server 2005 and up as the system stored procedures which I use were not included until SQL Server 2005.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/how-to-setup-a-server-to-read-log-files-nightly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is the BACKUPTHREAD wait type?</title>
		<link>http://itknowledgeexchange.techtarget.com/sql-server/what-is-the-backupthread-wait-type/</link>
		<comments>http://itknowledgeexchange.techtarget.com/sql-server/what-is-the-backupthread-wait-type/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 08:00:16 +0000</pubDate>
		<dc:creator>Denny Cherry</dc:creator>
				<category><![CDATA[Recovery]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/sql-server/what-is-the-backupthread-wait-type/</guid>
		<description><![CDATA[If you have ever seen the BACKUPTHREAD wait type in the sysprocesses table or sp_who2 output and wondered what it is, I have found the answer.]]></description>
				<content:encoded><![CDATA[<p>If you have ever seen the BACKUPTHREAD wait type in the sysprocesses table or sp_who2 output and wondered what it is, I have found the answer.</p>
<p>The basic explanation is &#8220;Used when waiting for a backup thread to complete.  Wait time may be very long (minutes, hours).&#8221;  Basically what this means is that there is a backup running and something is waiting for it to complete.</p>
<p>When i saw this show up I was running a restore.  That restore had three entries in the sysprocesses table.  The first was the main kpid, with two child kpids.  The parent kpid was the wait type of BACKUPTHREAD while it was waiting for the child kpid to finish processing.  In my case the wait time was short, and it seamed to switch from this wait type to an IO wait type.</p>
<p>Denny</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/sql-server/what-is-the-backupthread-wait-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
