<?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/"
		>
<channel>
	<title>Comments on: Script to get row count for all the tables in all the databases</title>
	<atom:link href="http://sql-articles.com/blogs/script-to-get-row-count-for-all-the-tables-in-all-the-databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://sql-articles.com/blogs/script-to-get-row-count-for-all-the-tables-in-all-the-databases/</link>
	<description>One Stop for SQL Server related Queries</description>
	<lastBuildDate>Thu, 09 Sep 2010 03:01:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Vidhya Sagar</title>
		<link>http://sql-articles.com/blogs/script-to-get-row-count-for-all-the-tables-in-all-the-databases/comment-page-1/#comment-232</link>
		<dc:creator>Vidhya Sagar</dc:creator>
		<pubDate>Mon, 12 Apr 2010 22:50:47 +0000</pubDate>
		<guid isPermaLink="false">http://sql-articles.com/blogs/script-to-get-row-count-for-all-the-tables-in-all-the-databases/#comment-232</guid>
		<description>Some times it happens in sql2k when it has more rows and also for other reasons. I&#039;ve replaced table variable with temp table, now it should run fine, try the query below

&lt;code&gt;SET NOCOUNT ON
DECLARE @query VARCHAR(4000)
IF EXISTS (SELECT 1 FROM tempdb..sysobjects WHERE name =&#039;##temp&#039;)
DROP TABLE ##temp
CREATE TABLE ##temp (DBName VARCHAR(200),TABLEName VARCHAR(300), COUNT INT)
SET @query=&#039;SELECT  &#039;&#039;?&#039;&#039;,SO.Name, SI.Rows
FROM   ?..sysobjects AS SO INNER JOIN ?..sysindexes AS SI ON SO.id = SI.id
WHERE  SO.type = &#039;&#039;U&#039;&#039;  AND SI.IndId &lt; 2 order by SO.Name&#039;
INSERT ##temp
EXEC sp_msforeachdb @query
SELECT * FROM ##temp WHERE DBName  &#039;tempdb&#039; ORDER BY DBName
DROP TABLE ##temp&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Some times it happens in sql2k when it has more rows and also for other reasons. I&#8217;ve replaced table variable with temp table, now it should run fine, try the query below</p>
<p><code>SET NOCOUNT ON<br />
DECLARE @query VARCHAR(4000)<br />
IF EXISTS (SELECT 1 FROM tempdb..sysobjects WHERE name ='##temp')<br />
DROP TABLE ##temp<br />
CREATE TABLE ##temp (DBName VARCHAR(200),TABLEName VARCHAR(300), COUNT INT)<br />
SET @query='SELECT  ''?'',SO.Name, SI.Rows<br />
FROM   ?..sysobjects AS SO INNER JOIN ?..sysindexes AS SI ON SO.id = SI.id<br />
WHERE  SO.type = ''U''  AND SI.IndId &lt; 2 order by SO.Name&#039;<br />
INSERT ##temp<br />
EXEC sp_msforeachdb @query<br />
SELECT * FROM ##temp WHERE DBName  'tempdb' ORDER BY DBName<br />
DROP TABLE ##temp</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deen</title>
		<link>http://sql-articles.com/blogs/script-to-get-row-count-for-all-the-tables-in-all-the-databases/comment-page-1/#comment-231</link>
		<dc:creator>Deen</dc:creator>
		<pubDate>Mon, 12 Apr 2010 22:31:29 +0000</pubDate>
		<guid isPermaLink="false">http://sql-articles.com/blogs/script-to-get-row-count-for-all-the-tables-in-all-the-databases/#comment-231</guid>
		<description>I get the following while executing your script in SQL 2000
EXECUTE cannot be used as a source when inserting into a table variable.</description>
		<content:encoded><![CDATA[<p>I get the following while executing your script in SQL 2000<br />
EXECUTE cannot be used as a source when inserting into a table variable.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
