<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Tech Off - SQL Server System Tables</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - SQL Server System Tables</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Mon, 20 May 2013 15:51:51 GMT</pubDate>
	<lastBuildDate>Mon, 20 May 2013 15:51:51 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>4</c9:totalResults>
	<c9:pageCount>-4</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - SQL Server System Tables</title>
		<description><![CDATA[<p>Just had an issue running sp_delete_backuphistory where the stored procedure would never complete (we left it run overnight). The stored procedure hadn't been run in a while on this server so the backupset and related tables were quite large (over 100,000
 rows), after looking at the source of this stored procedure I have two comments/questions:<br /><br />1. Why does this stored procedure use a cursor? As far as I can tell there is nothing in it that couldn't be done in set operations.<br /><br />2. Why aren't there any useful indexes on the backupset table? Simply adding an index to backup_finish_date improved the speed of this stored procedure a huge amount.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/5194-SQL-Server-System-Tables/5194#5194</link>
		<pubDate>Fri, 30 Apr 2004 00:07:26 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/5194-SQL-Server-System-Tables/5194#5194</guid>
		<dc:creator>wbarthol</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/wbarthol/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - SQL Server System Tables</title>
		<description><![CDATA[<p>I have no good answer for either of these questions.<br />&nbsp;<br />This has come up a couple of times in support cases and the solution has been a re-write of the SP, or a mixture of delete / truncate against the tables.
<br /><br />Hopefully you have a working solution you can use ( i presume indexing helped <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> ) ? If not, let me know and i can forward you on a potential alternative...<br /><br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/5194-SQL-Server-System-Tables/fdca45dc0f684686acf99dea010f901d#fdca45dc0f684686acf99dea010f901d</link>
		<pubDate>Fri, 30 Apr 2004 05:11:38 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/5194-SQL-Server-System-Tables/fdca45dc0f684686acf99dea010f901d#fdca45dc0f684686acf99dea010f901d</guid>
		<dc:creator>spod</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/spod/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - SQL Server System Tables</title>
		<description><![CDATA[<p>The indexing helps as long as you are still only deleting small batches, if you have a rewrite of the stored procedure you could easily send me that would save me&nbsp;some time in rewriting it myself (although it's not a particularly complicated proc).</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/5194-SQL-Server-System-Tables/d7a1724a985c4bfea2059dea010f9047#d7a1724a985c4bfea2059dea010f9047</link>
		<pubDate>Fri, 30 Apr 2004 05:35:23 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/5194-SQL-Server-System-Tables/d7a1724a985c4bfea2059dea010f9047#d7a1724a985c4bfea2059dea010f9047</guid>
		<dc:creator>wbarthol</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/wbarthol/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - SQL Server System Tables</title>
		<description><![CDATA[<p>We had the identical situation occur using sp_delete_backuphistory on a 2.5 GB MSDB. Most of which was backup history.
<br /><br />Here's the way I've worked around the issue. Keep in mind that we blew away all history, because we simply don't use it, but you can augment the routine if you use backup history in any way. Then, you'll have to&nbsp;augment&nbsp;the code below to work for you.<br />&nbsp;<br />Keep in mind this is not a Microsoft supported solution.<br /><br />1.&gt; To get started, get a base line of what's in those&nbsp;tables that you want to delete.<br /><br />select count(*) from dbo.backupfile<br />select count(*) from dbo.backupmediafamily<br />select count(*) from dbo.backupmediaset<br />select count(*) from dbo.backupset<br />select count(*) from dbo.restorefile<br />select count(*) from dbo.restorefilegroup<br />select count(*) from dbo.restorehistory<br /><br />2.&gt; Now, Restore msdb to an alternate database. We restored to msdb1. Let SQL do it's thing unhindered by giving it msdb without your tinkering.&nbsp;You'll do the deletes on this database and then restore it back to msdb. Keep in mind that you don't want to create
 any new jobs that'll get erased when you restore this older, but smaller,&nbsp;msdb database.<br /><br />3.&gt; For the following tables check all the foreign key relationships and select cascade delete on every corresponding primary key.<br /><br />Note,&nbsp;I tried to remove all relationships and truncate data from every table, but found that SQL would not let us add relationships back to the system tables. However, it will allow adding/removing the cadcade delete option.<br /><br />4.&gt; Once you're sure that you've added cascade delete to all those relationships, create a SQL job that runs the following statement.<br /><br />use msdb1<br />delete from backupmediaset<br /><br />5.&gt; Run the job you just created and wait a while. Our delete took a little less than 3.5 hours for about 2.5 GB of backup history data.<br /><br />6.&gt; Let the job complete, backup msdb1, and restore to msdb.<br /><br />I&nbsp;ran the following statements to oust&nbsp;connections to msdb so we could restore it. (lines are wrapping here)<br /><br />alter database msdb set restricted_user with rollback immediate<br />go<br />RESTORE DATABASE [msdb]<br />FROM DISK=<br />'s:\msdb1.bak'</p>
<p>WITH REPLACE,<br />move 'MSDBData' TO 'R:\Program Files\Microsoft SQL Server\MSSQL$I2KMCDC1\Data\msdbdata.mdf',<br />move 'MSDBLog' TO 'R:\Program Files\Microsoft SQL Server\MSSQL$I2KMCDC1\Data\msdblog.ldf'<br />Go<br /><br />7.&gt; After the restore, you'll notice the job you created to run the delete, disappears and that your msdb mdf file is much, much, smaller.<br /><br />8.&gt; Run the following to verify:<br /><br />select count(*) from dbo.backupfile<br />select count(*) from dbo.backupmediafamily<br />select count(*) from dbo.backupmediaset<br />select count(*) from dbo.backupset<br />select count(*) from dbo.restorefile<br />select count(*) from dbo.restorefilegroup<br />select count(*) from dbo.restorehistory<br /><br />9.&gt; Remove all the cascade deletes from the backup/restore table relationships in msdb.<br /><br />10.&gt;&nbsp;I'm going to try to run sp_delete_backuphistory on a regular basis instead of waiting so long. Hopefully, we won't have to do this again.<br /><br />***Keep your old original msdb backup copy around for a few weeks&nbsp;in case you discover any anomalies.<br /><br /><br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/5194-SQL-Server-System-Tables/bd06f20bf3084018851d9dea010f9094#bd06f20bf3084018851d9dea010f9094</link>
		<pubDate>Fri, 07 May 2004 12:29:59 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/5194-SQL-Server-System-Tables/bd06f20bf3084018851d9dea010f9094#bd06f20bf3084018851d9dea010f9094</guid>
		<dc:creator>flotsam</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/flotsam/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>