<?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> &#187; bloating</title>
	<atom:link href="http://benchmarkitconsulting.com/tag/bloating/feed/" rel="self" type="application/rss+xml" />
	<link>http://benchmarkitconsulting.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 12:54:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Bloated MSDB database</title>
		<link>http://benchmarkitconsulting.com/colin-stasiuk/2009/07/07/bloated-msdb-database/</link>
		<comments>http://benchmarkitconsulting.com/colin-stasiuk/2009/07/07/bloated-msdb-database/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 15:19:16 +0000</pubDate>
		<dc:creator>Colin Stasiuk</dc:creator>
				<category><![CDATA[Benchmark IT Consulting]]></category>
		<category><![CDATA[Colin Stasiuk]]></category>
		<category><![CDATA[Maintenance]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[bloat]]></category>
		<category><![CDATA[bloating]]></category>
		<category><![CDATA[msdb]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://benchmarkitconsulting.com/?p=803</guid>
		<description><![CDATA[So how do you drop databases? Do you use a simple DROP DATABASE statement? Do you detach the database and remove the files manually? Do you use the GUI? Run these two quick and dirty queries for me: SELECT COUNT(*) FROM   msdb.dbo.backupset SELECT COUNT(*) FROM   msdb.dbo.backupset WHERE  database_name NOT IN (SELECT name FROM master.dbo.sysdatabases)   So how much of your MSDB database is filled with backup [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-804" title="ierjflks" src="http://benchmarkitconsulting.com/wp-content/uploads/2009/07/ierjflks.jpg" alt="ierjflks" width="127" height="194" /></p>
<p>So how do you drop databases?</p>
<p>Do you use a simple DROP DATABASE statement?</p>
<p>Do you detach the database and remove the files manually?</p>
<p>Do you use the GUI?</p>
<p>Run these two quick and dirty queries for me:</p>
<p><code style="font-size: 12px;"><span style="color:blue">SELECT </span><span style="color:magenta">COUNT</span><span style="color:gray">(*)<br />
</span><span style="color:blue">FROM   </span><span style="color:black">msdb.dbo.backupset</span></code></p>
<p><code style="font-size: 12px;"><span style="color:blue">SELECT </span><span style="color:magenta">COUNT</span><span style="color:gray">(*)<br />
</span><span style="color:blue">FROM   </span><span style="color:black">msdb.dbo.backupset<br />
</span><span style="color:blue">WHERE  </span><span style="color:black">database_name </span><span style="color:gray">NOT </span><span style="color:blue">IN </span><span style="color:gray">(</span><span style="color:blue">SELECT </span><span style="color:black">name </span><span style="color:blue">FROM </span><span style="color:black">master.dbo.sysdatabases</span><span style="color:gray">)</span></code></p>
<p> </p>
<p><img class="alignnone size-full wp-image-805" title="fdlkfldkd" src="http://benchmarkitconsulting.com/wp-content/uploads/2009/07/fdlkfldkd.gif" alt="fdlkfldkd" width="144" height="145" /></p>
<p>So how much of your MSDB database is filled with backup history of databases that have long since been dropped from your instance?</p>
<p>MSDB love and care is not something that usually gets alot of press but if you&#8217;re a stickler for wanting to keep things neat and tidy take a look at the information in your MSDB and whether or not you&#8217;re storing (and backing up) more data then you need to.</p>
<p>Want to rid yourself of some MSDB bloating?</p>
<p><code style="font-size: 12px;"><span style="color:blue">SELECT DISTINCT</span><span style="color:gray">(</span><span style="color:black">database_name</span><span style="color:gray">)<br />
</span><span style="color:blue">FROM   </span><span style="color:black">msdb.dbo.backupset<br />
</span><span style="color:blue">WHERE  </span><span style="color:black">database_name </span><span style="color:gray">NOT </span><span style="color:blue">IN </span><span style="color:gray">(</span><span style="color:blue">SELECT </span><span style="color:black">name </span><span style="color:blue">FROM </span><span style="color:black">master.dbo.sysdatabases</span><span style="color:gray">)</span></code></p>
<p>So now that you have a list of those old databases that still have backup history kicking around&#8230; now what?</p>
<p>Don&#8217;t jump the gun and write a DELETE statement for msdb.dbo.backupset&#8230; what about the other backup tables like backupfile, etc?</p>
<p>Answer: msdb.dbo.sp_delete_database_backuphistory</p>
<p><code style="font-size: 12px;"><span style="color:blue">EXEC&nbsp;</span><span style="color:black">msdb.dbo.</span><span style="color:darkred">sp_delete_database_backuphistory&nbsp;</span><span style="color:#434343">@db_nm&nbsp;</span><span style="color:blue">=&nbsp;</span><span style="color:red">N&#39;&lt;&lt;DATABASE_NAME&gt;&gt;&#39;</p>
<p></span></code></p>
<p>Using this system stored procedure you&#8217;ll ensure that you&#8217;ve removed all the backup history for the specified database.</p>
<p>(As always, please use with caution)</p>
<p>Enjoy!!</p>
<p><span><a href="http://benchmarkitconsulting.com" target="_blank"><img class="alignnone size-full wp-image-402" title="benchmark_sm" src="http://benchmarkitconsulting.com/wp-content/uploads/2009/02/benchmark_sm.jpg" alt="" width="157" height="74" /></a><a href="http://sqlserverpedia.com/wiki/Editors#Colin_Stasiuk" target="_blank"><img src="http://sqlserverpedia.com/badges/SQLServerPedia_Badge_Blogger.jpg" alt="" width="120" height="60" /> </a></span></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Bloated+MSDB+database+http://tinyurl.com/ljtr6r" title="Post to Twitter"><img class="nothumb" src="http://benchmarkitconsulting.com/wp-content/plugins/tweet-this/icons/tt-twitter-big4.png" alt="Post to Twitter" /></a> <a class="tt" href="http://delicious.com/post?url=http://benchmarkitconsulting.com/colin-stasiuk/2009/07/07/bloated-msdb-database/&amp;title=Bloated+MSDB+database" title="Post to Delicious"><img class="nothumb" src="http://benchmarkitconsulting.com/wp-content/plugins/tweet-this/icons/tt-delicious-big4.png" alt="Post to Delicious" /></a> <a class="tt" href="http://digg.com/submit?url=http://benchmarkitconsulting.com/colin-stasiuk/2009/07/07/bloated-msdb-database/&amp;title=Bloated+MSDB+database" title="Post to Digg"><img class="nothumb" src="http://benchmarkitconsulting.com/wp-content/plugins/tweet-this/icons/tt-digg-big4.png" alt="Post to Digg" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://benchmarkitconsulting.com/colin-stasiuk/2009/07/07/bloated-msdb-database/&amp;title=Bloated+MSDB+database" title="Post to StumbleUpon"><img class="nothumb" src="http://benchmarkitconsulting.com/wp-content/plugins/tweet-this/icons/tt-su-big4.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://benchmarkitconsulting.com/colin-stasiuk/2009/07/07/bloated-msdb-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

