<?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>Isaac&#039;s Blog &#187; sql 2005</title>
	<atom:link href="http://blog.isaacblum.com/tag/sql-2005/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.isaacblum.com</link>
	<description>So Many Rambles So Little Time....</description>
	<lastBuildDate>Wed, 28 Dec 2011 21:10:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Get Tables Sizes for a Database</title>
		<link>http://blog.isaacblum.com/2009/11/06/get-tables-sizes-for-a-database/</link>
		<comments>http://blog.isaacblum.com/2009/11/06/get-tables-sizes-for-a-database/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 21:08:54 +0000</pubDate>
		<dc:creator>IsaacBlum</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[sql 2005]]></category>
		<category><![CDATA[table size]]></category>
		<category><![CDATA[tsql]]></category>

		<guid isPermaLink="false">http://blog.isaacblum.com/?p=198</guid>
		<description><![CDATA[Thanks  to http://www.pgrconsulting.com/useful_p_and_t.htm  &#8211; Create the temp table for further querying CREATE TABLE #temp(             rec_id               int IDENTITY (1, 1),             table_name       varchar(128),             nbr_of_rows     int,             data_space       decimal(15,2),             index_space     decimal(15,2),             total_size          decimal(15,2),             percent_of_db  decimal(15,12),             db_size             decimal(15,2)) &#160; &#8211; Get all tables, names, and sizes EXEC sp_msforeachtable @command1=&#8221;insert into #temp(nbr_of_rows, data_space, [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks  to <a href="http://www.pgrconsulting.com/useful_p_and_t.htm">http://www.pgrconsulting.com/useful_p_and_t.htm</a> </p>
<p>&#8211; Create the temp table for further querying</p>
<p>CREATE TABLE #temp(</p>
<p>            rec_id               int IDENTITY (1, 1),</p>
<p>            table_name       varchar(128),</p>
<p>            nbr_of_rows     int,</p>
<p>            data_space       decimal(15,2),</p>
<p>            index_space     decimal(15,2),</p>
<p>            total_size          decimal(15,2),</p>
<p>            percent_of_db  decimal(15,12),</p>
<p>            db_size             decimal(15,2))</p>
<p>&nbsp;</p>
<p>&#8211; Get all tables, names, and sizes</p>
<p>EXEC sp_msforeachtable @command1=&#8221;insert into #temp(nbr_of_rows, data_space, index_space) exec sp_mstablespace &#8216;?&#8217;&#8221;,</p>
<p>                                    @command2=&#8221;update #temp set table_name = &#8216;?&#8217; where rec_id = (select max(rec_id) from #temp)&#8221;</p>
<p>&nbsp;</p>
<p>&#8211; Set the total_size and total database size fields</p>
<p>UPDATE #temp</p>
<p>SET total_size = (data_space + index_space), db_size = (SELECT SUM(data_space + index_space) FROM #temp)</p>
<p>&nbsp;</p>
<p>&#8211; Set the percent of the total database size</p>
<p>UPDATE #temp</p>
<p>SET percent_of_db = (total_size/db_size) * 100</p>
<p>&nbsp;</p>
<p>&#8211; Get the data</p>
<p>SELECT *</p>
<p>FROM #temp</p>
<p>ORDER BY total_size DESC</p>
<p>&nbsp;</p>
<p>&#8211; Comment out the following line if you want to do further querying</p>
<p>DROP TABLE #temp</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.isaacblum.com/2009/11/06/get-tables-sizes-for-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

