<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER – Find Row Count in Table – Find Largest Table in Database – Part 2</title>
	<atom:link href="http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sat, 25 May 2013 01:31:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: WayneNZL</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-474650</link>
		<dc:creator><![CDATA[WayneNZL]]></dc:creator>
		<pubDate>Mon, 13 May 2013 21:00:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-474650</guid>
		<description><![CDATA[Thanks for the code, I&#039;ve modified it a bit;

SELECT QUOTENAME(SCHEMA_NAME([OBJ].[schema_id])) +&#039;.&#039;+ QUOTENAME([OBJ].[name]) AS [table_name]
	,SUM([PAR].[rows]) AS [row_count]
FROM sys.objects [OBJ]
	INNER JOIN sys.partitions [PAR]
		ON [PAR].OBJECT_ID = [OBJ].OBJECT_ID
WHERE [OBJ].[type] = &#039;U&#039;
	AND is_ms_shipped = 0
	AND [PAR].[index_id] IN (1,0)
GROUP BY [OBJ].[schema_id]
	,[OBJ].[name]
ORDER BY SUM([PAR].[rows]) DESC]]></description>
		<content:encoded><![CDATA[<p>Thanks for the code, I&#8217;ve modified it a bit;</p>
<p>SELECT QUOTENAME(SCHEMA_NAME([OBJ].[schema_id])) +&#8217;.'+ QUOTENAME([OBJ].[name]) AS [table_name]<br />
	,SUM([PAR].[rows]) AS [row_count]<br />
FROM sys.objects [OBJ]<br />
	INNER JOIN sys.partitions [PAR]<br />
		ON [PAR].OBJECT_ID = [OBJ].OBJECT_ID<br />
WHERE [OBJ].[type] = &#8216;U&#8217;<br />
	AND is_ms_shipped = 0<br />
	AND [PAR].[index_id] IN (1,0)<br />
GROUP BY [OBJ].[schema_id]<br />
	,[OBJ].[name]<br />
ORDER BY SUM([PAR].[rows]) DESC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Identify Most Resource Intensive Queries &#8211; SQL in Sixty Seconds #029 &#8211; Video &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-358098</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Identify Most Resource Intensive Queries &#8211; SQL in Sixty Seconds #029 &#8211; Video &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Wed, 10 Oct 2012 01:32:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-358098</guid>
		<description><![CDATA[[...] Find Row Count in Table – Find Largest Table in Database [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Find Row Count in Table – Find Largest Table in Database [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhanumjay</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-303192</link>
		<dc:creator><![CDATA[Dhanumjay]]></dc:creator>
		<pubDate>Tue, 19 Jun 2012 12:42:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-303192</guid>
		<description><![CDATA[We can use Object_Schema_Name()function to get the schema name of an object. So we can just use this function in your previous query to count the rows of all tables as follows.
select OBJECT_SCHEMA_NAME(object_id)+&#039;.&#039;+OBJECT_NAME(object_id) as tablename,row_count
from sys.dm_db_partition_stats 
where (index_id &lt; 2) 
order by row_count desc;]]></description>
		<content:encoded><![CDATA[<p>We can use Object_Schema_Name()function to get the schema name of an object. So we can just use this function in your previous query to count the rows of all tables as follows.<br />
select OBJECT_SCHEMA_NAME(object_id)+&#8217;.'+OBJECT_NAME(object_id) as tablename,row_count<br />
from sys.dm_db_partition_stats<br />
where (index_id &lt; 2)<br />
order by row_count desc;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shru</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-202148</link>
		<dc:creator><![CDATA[shru]]></dc:creator>
		<pubDate>Tue, 22 Nov 2011 11:36:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-202148</guid>
		<description><![CDATA[Thnx for the above query, I helped me a lot!! :)]]></description>
		<content:encoded><![CDATA[<p>Thnx for the above query, I helped me a lot!! :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: subash</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-118663</link>
		<dc:creator><![CDATA[subash]]></dc:creator>
		<pubDate>Tue, 15 Feb 2011 17:23:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-118663</guid>
		<description><![CDATA[Ammena&#039;s script as presented here by Pinal didn&#039;t give me the precise row counts for table. It worked for smaller tables, but row counts were way off in larger tables. I have
modified Ameena&#039;s script to get the precise count as following:

select sc.name +&#039;.&#039;+ ta.name
--,sum(pa.rows) -- Approximate value, oh well
,ps.row_count
from sys.tables ta
inner join sys.partitions pa
on pa.object_id = ta.object_id
inner join sys.dm_db_partition_stats ps
on ta.object_id = ps.object_id
inner join sys.schemas sc
on ta.schema_id = sc.schema_id
where ta.is_ms_shipped = 0 AND pa.index_id IN (1,0)
group by sc.name,ta.name,ps.row_count
ORDER BY sum(pa.rows) DESC]]></description>
		<content:encoded><![CDATA[<p>Ammena&#8217;s script as presented here by Pinal didn&#8217;t give me the precise row counts for table. It worked for smaller tables, but row counts were way off in larger tables. I have<br />
modified Ameena&#8217;s script to get the precise count as following:</p>
<p>select sc.name +&#8217;.'+ ta.name<br />
&#8211;,sum(pa.rows) &#8212; Approximate value, oh well<br />
,ps.row_count<br />
from sys.tables ta<br />
inner join sys.partitions pa<br />
on pa.object_id = ta.object_id<br />
inner join sys.dm_db_partition_stats ps<br />
on ta.object_id = ps.object_id<br />
inner join sys.schemas sc<br />
on ta.schema_id = sc.schema_id<br />
where ta.is_ms_shipped = 0 AND pa.index_id IN (1,0)<br />
group by sc.name,ta.name,ps.row_count<br />
ORDER BY sum(pa.rows) DESC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nitin</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-93584</link>
		<dc:creator><![CDATA[Nitin]]></dc:creator>
		<pubDate>Sat, 16 Oct 2010 08:13:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-93584</guid>
		<description><![CDATA[How bout this?

SELECT  rows ,
        SCHEMA_NAME(t.schema_id) + &#039;.&#039; + OBJECT_NAME(t.OBJECT_ID)
FROM    sys.tables t
        JOIN sys.partitions p ON t.object_id = p.object_id AND p.index_id IN (0,1)	
ORDER BY 1 DESC]]></description>
		<content:encoded><![CDATA[<p>How bout this?</p>
<p>SELECT  rows ,<br />
        SCHEMA_NAME(t.schema_id) + &#8216;.&#8217; + OBJECT_NAME(t.OBJECT_ID)<br />
FROM    sys.tables t<br />
        JOIN sys.partitions p ON t.object_id = p.object_id AND p.index_id IN (0,1)<br />
ORDER BY 1 DESC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imtiaz</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87251</link>
		<dc:creator><![CDATA[Imtiaz]]></dc:creator>
		<pubDate>Thu, 09 Sep 2010 15:52:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87251</guid>
		<description><![CDATA[Also note - the title of the blog is named &quot;Find Row Count in Table – Find Largest Table in Database&quot;.

The original result does not bring the largest table, simply the most number of rows.
This does not necessarily mean it&#039;s the largest table.
The solution I posted above does however give us a way to view the results by any of the sizeable measures for an object, along with a dynamic sort for the user, thus resulting in a &#039;Find Row Counts&#039; and &#039;Find largest table&#039; method.

:)
Imtiaz]]></description>
		<content:encoded><![CDATA[<p>Also note &#8211; the title of the blog is named &#8220;Find Row Count in Table – Find Largest Table in Database&#8221;.</p>
<p>The original result does not bring the largest table, simply the most number of rows.<br />
This does not necessarily mean it&#8217;s the largest table.<br />
The solution I posted above does however give us a way to view the results by any of the sizeable measures for an object, along with a dynamic sort for the user, thus resulting in a &#8216;Find Row Counts&#8217; and &#8216;Find largest table&#8217; method.</p>
<p>:)<br />
Imtiaz</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramdas</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87169</link>
		<dc:creator><![CDATA[Ramdas]]></dc:creator>
		<pubDate>Thu, 09 Sep 2010 02:21:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87169</guid>
		<description><![CDATA[Good inputs in terms of different approaches for finding the rowcounts in tables.]]></description>
		<content:encoded><![CDATA[<p>Good inputs in terms of different approaches for finding the rowcounts in tables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mateus</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87106</link>
		<dc:creator><![CDATA[Mateus]]></dc:creator>
		<pubDate>Wed, 08 Sep 2010 16:50:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87106</guid>
		<description><![CDATA[Script doesn&#039;t work on SQL Server 2000.

If there&#039;s anyone intersted here&#039;s one that works:

SELECT o.name AS &quot;Table&quot;, i.rowcnt AS &quot;Rows&quot;
FROM sysobjects o, sysindexes i
WHERE i.id = o.id
AND indid IN(0,1)
AND xtype = &#039;u&#039;
AND o.name  &#039;sysdiagrams&#039;
ORDER BY i.rowcnt desc]]></description>
		<content:encoded><![CDATA[<p>Script doesn&#8217;t work on SQL Server 2000.</p>
<p>If there&#8217;s anyone intersted here&#8217;s one that works:</p>
<p>SELECT o.name AS &#8220;Table&#8221;, i.rowcnt AS &#8220;Rows&#8221;<br />
FROM sysobjects o, sysindexes i<br />
WHERE i.id = o.id<br />
AND indid IN(0,1)<br />
AND xtype = &#8216;u&#8217;<br />
AND o.name  &#8216;sysdiagrams&#8217;<br />
ORDER BY i.rowcnt desc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imtiaz</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87080</link>
		<dc:creator><![CDATA[Imtiaz]]></dc:creator>
		<pubDate>Wed, 08 Sep 2010 11:47:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87080</guid>
		<description><![CDATA[Whatever happened to good old Microsofts sp_spaceused?


create table #tablesize (	name varchar(50), 
							rows int, 
							reserved varchar(20), 
							data varchar(20), 
							index_size varchar(20), 
							unused varchar(20)
							)
							
exec sp_msForEachTable &#039;insert #tablesize exec sp_spaceused &#039;&#039;?&#039;&#039;&#039;

declare @sortorder tinyint
set @sortorder = 2

select	name, 
		replace(rows, &#039;KB&#039;, &#039;&#039;) as Rows, 
		convert(int,replace(reserved, &#039;KB&#039;, &#039;&#039;)) as TotalReserved, 
		convert(int,replace(data, &#039;KB&#039;, &#039;&#039;)) as DataSize, 
		convert(int,replace(index_size, &#039;KB&#039;, &#039;&#039;)) as IndexSize, 
		convert(int,replace(unused, &#039;KB&#039;, &#039;&#039;)) as Unused 
from #tablesize
order by case when @sortorder = 1 then Rows
			  when @sortorder = 2 then convert(int,replace(reserved, &#039;KB&#039;, &#039;&#039;))
			  when @sortorder = 3 then convert(int,replace(data, &#039;KB&#039;, &#039;&#039;))
			  when @sortorder = 4 then convert(int,replace(index_size, &#039;KB&#039;, &#039;&#039;))
			  when @sortorder = 5 then convert(int,replace(unused, &#039;KB&#039;, &#039;&#039;))
			  else Rows
			  end desc
				
drop table #tablesize]]></description>
		<content:encoded><![CDATA[<p>Whatever happened to good old Microsofts sp_spaceused?</p>
<p>create table #tablesize (	name varchar(50),<br />
							rows int,<br />
							reserved varchar(20),<br />
							data varchar(20),<br />
							index_size varchar(20),<br />
							unused varchar(20)<br />
							)</p>
<p>exec sp_msForEachTable &#8216;insert #tablesize exec sp_spaceused &#8221;?&#8221;&#8217;</p>
<p>declare @sortorder tinyint<br />
set @sortorder = 2</p>
<p>select	name,<br />
		replace(rows, &#8216;KB&#8217;, &#8221;) as Rows,<br />
		convert(int,replace(reserved, &#8216;KB&#8217;, &#8221;)) as TotalReserved,<br />
		convert(int,replace(data, &#8216;KB&#8217;, &#8221;)) as DataSize,<br />
		convert(int,replace(index_size, &#8216;KB&#8217;, &#8221;)) as IndexSize,<br />
		convert(int,replace(unused, &#8216;KB&#8217;, &#8221;)) as Unused<br />
from #tablesize<br />
order by case when @sortorder = 1 then Rows<br />
			  when @sortorder = 2 then convert(int,replace(reserved, &#8216;KB&#8217;, &#8221;))<br />
			  when @sortorder = 3 then convert(int,replace(data, &#8216;KB&#8217;, &#8221;))<br />
			  when @sortorder = 4 then convert(int,replace(index_size, &#8216;KB&#8217;, &#8221;))<br />
			  when @sortorder = 5 then convert(int,replace(unused, &#8216;KB&#8217;, &#8221;))<br />
			  else Rows<br />
			  end desc</p>
<p>drop table #tablesize</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalpesh</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87054</link>
		<dc:creator><![CDATA[Kalpesh]]></dc:creator>
		<pubDate>Wed, 08 Sep 2010 09:25:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87054</guid>
		<description><![CDATA[SELECT os.name, ob.name, ind.rowcnt
FROM sys.sysindexes ind
	INNER JOIN sys.objects ob
		ON ind.id = ob.Object_id
	INNER JOIN sys.schemas os
		ON ob.Schema_id = os.Schema_id
WHERE ob.type=&#039;u&#039; and indid&lt;2
ORDER BY ind.rowcnt desc]]></description>
		<content:encoded><![CDATA[<p>SELECT os.name, ob.name, ind.rowcnt<br />
FROM sys.sysindexes ind<br />
	INNER JOIN sys.objects ob<br />
		ON ind.id = ob.Object_id<br />
	INNER JOIN sys.schemas os<br />
		ON ob.Schema_id = os.Schema_id<br />
WHERE ob.type=&#8217;u&#8217; and indid&lt;2<br />
ORDER BY ind.rowcnt desc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87040</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Wed, 08 Sep 2010 07:58:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87040</guid>
		<description><![CDATA[Indid filter is important. Otherwise you will get duplicate rows]]></description>
		<content:encoded><![CDATA[<p>Indid filter is important. Otherwise you will get duplicate rows</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87039</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Wed, 08 Sep 2010 07:49:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87039</guid>
		<description><![CDATA[Here are some other methods to know the row count from the tables
http://beyondrelational.com/blogs/madhivanan/archive/2007/11/02/different-ways-to-count-rows-from-a-table.aspx]]></description>
		<content:encoded><![CDATA[<p>Here are some other methods to know the row count from the tables<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2007/11/02/different-ways-to-count-rows-from-a-table.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2007/11/02/different-ways-to-count-rows-from-a-table.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Feodor</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87030</link>
		<dc:creator><![CDATA[Feodor]]></dc:creator>
		<pubDate>Wed, 08 Sep 2010 06:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87030</guid>
		<description><![CDATA[Actually, I prefer the SSMS reports. If you right-click on the database in the SSMS and you choose Reports --&gt; Standard Reports and then you choose &quot;Disk Usage by Table&quot; you will get a report which shows not only the row count, but also the Reserved space, the data space, the index space and the unused space. All this information is very important when considering performance, scalability and even future designing of the system. I have seen tables with 100,000 rows which were more problematic than tables with 40 million rows.]]></description>
		<content:encoded><![CDATA[<p>Actually, I prefer the SSMS reports. If you right-click on the database in the SSMS and you choose Reports &#8211;&gt; Standard Reports and then you choose &#8220;Disk Usage by Table&#8221; you will get a report which shows not only the row count, but also the Reserved space, the data space, the index space and the unused space. All this information is very important when considering performance, scalability and even future designing of the system. I have seen tables with 100,000 rows which were more problematic than tables with 40 million rows.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kuldeep Mathur</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87020</link>
		<dc:creator><![CDATA[Kuldeep Mathur]]></dc:creator>
		<pubDate>Wed, 08 Sep 2010 04:45:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87020</guid>
		<description><![CDATA[I thnk ths is more smple qry for doing this wrk.

Select a.Name as TblName,Sum(b.Rows) as RowsCount from Sys.Tables as a,Sys.Partitions as b where a.Object_Id=b.Object_Id  Group By a.Name Order By Sum(Rows) Desc]]></description>
		<content:encoded><![CDATA[<p>I thnk ths is more smple qry for doing this wrk.</p>
<p>Select a.Name as TblName,Sum(b.Rows) as RowsCount from Sys.Tables as a,Sys.Partitions as b where a.Object_Id=b.Object_Id  Group By a.Name Order By Sum(Rows) Desc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blog.sqlauthority.com/2010/09/08/sql-server-find-row-count-in-table-find-largest-table-in-database-part-2/#comment-87006</link>
		<dc:creator><![CDATA[Doug]]></dc:creator>
		<pubDate>Wed, 08 Sep 2010 02:15:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=10145#comment-87006</guid>
		<description><![CDATA[If you&#039;re using SSMS with SQL Server 2008 you can:
1. Go to Object Explorer Window and select the Tables folder in the database of interest.
2. Hit F7 to bring up Object Explorer Details Window.
3. Right Click on the column headings in the new window and add a column called Row Count (similar to the way Windows Explorer lets you add columns).
4. Once you&#039;ve added the column click on the refresh button.  5. Then click on the column heading again to sort by # of rows.]]></description>
		<content:encoded><![CDATA[<p>If you&#8217;re using SSMS with SQL Server 2008 you can:<br />
1. Go to Object Explorer Window and select the Tables folder in the database of interest.<br />
2. Hit F7 to bring up Object Explorer Details Window.<br />
3. Right Click on the column headings in the new window and add a column called Row Count (similar to the way Windows Explorer lets you add columns).<br />
4. Once you&#8217;ve added the column click on the refresh button.  5. Then click on the column heading again to sort by # of rows.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
