<?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: TSQL Count Number Of Stored Procedures, Views, Tables or Functions</title>
	<atom:link href="http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/</link>
	<description>Software Development: C#, SQL Server, .NET, Analysis Services, Reporting Services, Intergration Services, OLAP, PHP, HTML, XML, CSS, Java, Javascript and anything else technical, complex and hibbins.com</description>
	<lastBuildDate>Tue, 07 Feb 2012 09:24:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: shanmu</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-31699</link>
		<dc:creator>shanmu</dc:creator>
		<pubDate>Tue, 25 Oct 2011 13:21:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-31699</guid>
		<description>the most wanted statements in sql query......</description>
		<content:encoded><![CDATA[<p>the most wanted statements in sql query&#8230;&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Curtis</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-28121</link>
		<dc:creator>Curtis</dc:creator>
		<pubDate>Fri, 02 Sep 2011 16:25:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-28121</guid>
		<description>Thank you..very helpful</description>
		<content:encoded><![CDATA[<p>Thank you..very helpful</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sun</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-26524</link>
		<dc:creator>Sun</dc:creator>
		<pubDate>Fri, 05 Aug 2011 08:45:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-26524</guid>
		<description>Very useful Queries..</description>
		<content:encoded><![CDATA[<p>Very useful Queries..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karnatakapu Mallikarjun</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-23813</link>
		<dc:creator>Karnatakapu Mallikarjun</dc:creator>
		<pubDate>Tue, 21 Jun 2011 07:18:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-23813</guid>
		<description>Good one.</description>
		<content:encoded><![CDATA[<p>Good one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niranjan</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-21041</link>
		<dc:creator>Niranjan</dc:creator>
		<pubDate>Fri, 06 May 2011 12:40:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-21041</guid>
		<description>Good Job!!!</description>
		<content:encoded><![CDATA[<p>Good Job!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jabran</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-19643</link>
		<dc:creator>Jabran</dc:creator>
		<pubDate>Fri, 08 Apr 2011 21:23:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-19643</guid>
		<description>Count of Procedures and Functions across all databases on the server

Select name as databaseName, NULL as SPCount 
into #x 
from sys.databases where database_id &gt; 4
--drop table #x


Declare @databaseName varchar(30), @Query nvarchar(max)

While exists (select 1 from #x where Spcount is NULL)
	Begin
		Select top 1 @databaseName = databaseName from #x where SPCount is NULL
		Set @Query = 
    &#039;
	Update #x 
	Set Spcount = (SELECT count(*) FROM &#039; + @databaseName + &#039;.INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE in(&#039;&#039;PROCEDURE&#039;&#039;, &#039;&#039;FUNCTION&#039;&#039;))
	WHERE databaseName = &#039;&#039;&#039; + @databaseName + &#039;&#039;&#039;&#039;

	Print @Query
	exec sp_executesql @Query
	End
	

Select * from #x</description>
		<content:encoded><![CDATA[<p>Count of Procedures and Functions across all databases on the server</p>
<p>Select name as databaseName, NULL as SPCount<br />
into #x<br />
from sys.databases where database_id &gt; 4<br />
&#8211;drop table #x</p>
<p>Declare @databaseName varchar(30), @Query nvarchar(max)</p>
<p>While exists (select 1 from #x where Spcount is NULL)<br />
	Begin<br />
		Select top 1 @databaseName = databaseName from #x where SPCount is NULL<br />
		Set @Query =<br />
    &#8216;<br />
	Update #x<br />
	Set Spcount = (SELECT count(*) FROM &#8216; + @databaseName + &#8216;.INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE in(&#8221;PROCEDURE&#8221;, &#8221;FUNCTION&#8221;))<br />
	WHERE databaseName = &#8221;&#8217; + @databaseName + &#8221;&#8221;</p>
<p>	Print @Query<br />
	exec sp_executesql @Query<br />
	End</p>
<p>Select * from #x</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Divya Sooraj</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-19456</link>
		<dc:creator>Divya Sooraj</dc:creator>
		<pubDate>Tue, 05 Apr 2011 14:18:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-19456</guid>
		<description>Brilliant Work........Very helpful....Thanks alot.........!!</description>
		<content:encoded><![CDATA[<p>Brilliant Work&#8230;&#8230;..Very helpful&#8230;.Thanks alot&#8230;&#8230;&#8230;!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-17189</link>
		<dc:creator>John</dc:creator>
		<pubDate>Mon, 14 Feb 2011 10:24:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-17189</guid>
		<description>Very helpful.
Thanks Mate.</description>
		<content:encoded><![CDATA[<p>Very helpful.<br />
Thanks Mate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hiren</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-15846</link>
		<dc:creator>Hiren</dc:creator>
		<pubDate>Thu, 13 Jan 2011 05:00:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-15846</guid>
		<description>Thanks dude</description>
		<content:encoded><![CDATA[<p>Thanks dude</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: O.ver</title>
		<link>http://www.hibbins.com/2008/09/04/tsql-count-number-of-stored-procedures-views-tables-or-functions/comment-page-1/#comment-12259</link>
		<dc:creator>O.ver</dc:creator>
		<pubDate>Fri, 06 Aug 2010 14:02:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.hibbins.com/?p=155#comment-12259</guid>
		<description>This is helpful. Thanks!</description>
		<content:encoded><![CDATA[<p>This is helpful. Thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

