<?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>Moki Systems Blog &#187; Microsoft SQL Server</title>
	<atom:link href="http://www.mokisystems.com/blog/category/database-administration/microsoft-sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mokisystems.com/blog</link>
	<description>Addressing such topics as: web programming, design, ruby on rails, cake php, postgresql, linux, seo</description>
	<lastBuildDate>Thu, 19 Aug 2010 00:18:50 +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>How large is an individual table in Microsoft SQL Server</title>
		<link>http://www.mokisystems.com/blog/how-large-is-an-individual-table-in-microsoft-sql-server/</link>
		<comments>http://www.mokisystems.com/blog/how-large-is-an-individual-table-in-microsoft-sql-server/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 20:38:35 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>

		<guid isPermaLink="false">http://www.mokisystems.com/blog/?p=58</guid>
		<description><![CDATA[Some time ago I had a situation where a clients SQL database was about 70GB larger than they expected it to be. That is like 10 times larger than they expected.
They asked me to trouble shoot the problem; with no clue as to what the problem should be.
To begin with I decided to find out [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I had a situation where a clients SQL database was about 70GB larger than they expected it to be. That is like 10 times larger than they expected.</p>
<p>They asked me to trouble shoot the problem; with no clue as to what the problem should be.</p>
<p>To begin with I decided to find out the size of each individual table to determine if it was any particular table that was the problem.</p>
<p>To calculate the table sizes I wrote a query to put all of the table sizes into a table that could easily be read and shared with the client as follows:<br />
<code><br />
create table temp_tablesizes (</p>
<p>name varchar(250),</p>
<p>rows int,</p>
<p>reserved varchar(20),</p>
<p>data varchar(20),</p>
<p>index_size varchar(20),</p>
<p>unused varchar(20)</p>
<p>)</p>
<p>DECLARE @table_name varchar(250)</p>
<p>declare @res_name varchar(250)</p>
<p>DECLARE table_list CURSOR read_only</p>
<p>FOR SELECT TABLE_SCHEMA + '.' + TABLE_NAME AS Expr1</p>
<p>FROM         information_schema.tables                                                                                                                                              WHERE     (table_type = 'BASE TABLE')</p>
<p>ORDER BY TABLE_NAME OPEN table_list FETCH next</p>
<p>FROM         table_list</p>
<p>INTO @table_name</p>
<p>WHILE @@fetch_status = 0</p>
<p>BEGIN</p>
<p>insert into temp_tablesizes EXEC sp_spaceused @table_name</p>
<p>PRINT @table_name</p>
<p>FETCH next</p>
<p>FROM         table_list</p>
<p>INTO            @table_name END CLOSE table_list DEALLOCATE table_list</p>
<p></code></p>
<p>Looking at the table sizes in the temp_tablesizes database we discovered that 90% of the size was allocated to a table which was suppose to have a maximum of two records per account each record being a large sound file.  We discovered that the tool which deleted old recordings wasn&#8217;t working and where able to resolve the problem of an excessively large Microsoft SQL Server database.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mokisystems.com/blog/how-large-is-an-individual-table-in-microsoft-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
