<?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 &#8211; Find Table in Every Database of SQL Server</title>
	<atom:link href="http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/#comment-57318</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Wed, 04 Nov 2009 03:02:15 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=587#comment-57318</guid>
		<description>@Sandya

Exec sp_depends &#039;table_name&#039;

Result set returned, will contain all dependencies, like which other tables, views, stored procedure depend on this table

~IM</description>
		<content:encoded><![CDATA[<p>@Sandya</p>
<p>Exec sp_depends &#8216;table_name&#8217;</p>
<p>Result set returned, will contain all dependencies, like which other tables, views, stored procedure depend on this table</p>
<p>~IM</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sandya</title>
		<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/#comment-57304</link>
		<dc:creator>sandya</dc:creator>
		<pubDate>Tue, 03 Nov 2009 19:33:05 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=587#comment-57304</guid>
		<description>Can we find in all the stored procedures where the table is used?
If we alter the table and add a column, and want  to see where all the table is used in the stored procedures and functions.
How do we achieve that.</description>
		<content:encoded><![CDATA[<p>Can we find in all the stored procedures where the table is used?<br />
If we alter the table and add a column, and want  to see where all the table is used in the stored procedures and functions.<br />
How do we achieve that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/#comment-54040</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Fri, 24 Jul 2009 03:19:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=587#comment-54040</guid>
		<description>@Praveen 

-- Either make this a stored procedure or change value of @Column_Name, 

Code Starts here, 

Declare @Column_Name sysname
Set @Column_Name = &#039;eid&#039; 

Declare  @temp_variable table ([Database Name] sysname, [Schema Name] sysname,  [Table Name] sysname, [Column Name]  sysname , [Ordinal Position]Int, [Is Null] varchar(3), [Data type] varchar(50), [Length] int , [Precision] Int, [Scale] Int)

Declare @Sqlcmd1 nvarchar(4000)

Set @Sqlcmd1 = 
&#039;EXEC sp_msforeachdb
&#039;&#039;
USE ?
Select TABLE_CATALOG [Database Name]
,TABLE_SCHEMA [Schema Name]
,TABLE_NAME [Table Name]
,COLUMN_NAME [Column Name]
,ORDINAL_POSITION [Ordinal Position]
,IS_NULLABLE [Is Null]
,DATA_TYPE [Data Type]
,CHARACTER_MAXIMUM_LENGTH [Lenth]
,NUMERIC_PRECISION [Precision]
,NUMERIC_SCALE [Scale]
From Information_Schema.columns
Where COLUMN_NAME  = &#039;&#039;&#039;&#039;&#039;+@Column_Name+&#039;&#039;&#039;&#039;&#039;&#039;&#039;&#039;

Insert into @temp_variable Exec Sp_ExecuteSQL @Sqlcmd1

Select * from @temp_variable

~ IM.</description>
		<content:encoded><![CDATA[<p>@Praveen </p>
<p>&#8211; Either make this a stored procedure or change value of @Column_Name, </p>
<p>Code Starts here, </p>
<p>Declare @Column_Name sysname<br />
Set @Column_Name = &#8216;eid&#8217; </p>
<p>Declare  @temp_variable table ([Database Name] sysname, [Schema Name] sysname,  [Table Name] sysname, [Column Name]  sysname , [Ordinal Position]Int, [Is Null] varchar(3), [Data type] varchar(50), [Length] int , [Precision] Int, [Scale] Int)</p>
<p>Declare @Sqlcmd1 nvarchar(4000)</p>
<p>Set @Sqlcmd1 =<br />
&#8216;EXEC sp_msforeachdb<br />
&#8221;<br />
USE ?<br />
Select TABLE_CATALOG [Database Name]<br />
,TABLE_SCHEMA [Schema Name]<br />
,TABLE_NAME [Table Name]<br />
,COLUMN_NAME [Column Name]<br />
,ORDINAL_POSITION [Ordinal Position]<br />
,IS_NULLABLE [Is Null]<br />
,DATA_TYPE [Data Type]<br />
,CHARACTER_MAXIMUM_LENGTH [Lenth]<br />
,NUMERIC_PRECISION [Precision]<br />
,NUMERIC_SCALE [Scale]<br />
From Information_Schema.columns<br />
Where COLUMN_NAME  = &#8221;&#8221;&#8217;+@Column_Name+&#8221;&#8221;&#8221;&#8221;</p>
<p>Insert into @temp_variable Exec Sp_ExecuteSQL @Sqlcmd1</p>
<p>Select * from @temp_variable</p>
<p>~ IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: praveen</title>
		<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/#comment-54038</link>
		<dc:creator>praveen</dc:creator>
		<pubDate>Fri, 24 Jul 2009 00:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=587#comment-54038</guid>
		<description>Is there a way to query an entire sql server looking for a certain column? am trying to create an application where the users can search our entire sql server by a column name.I want the query to list the table name,database name,column name,column data type.
Any ideas or sample code will be greatly appreciated.

Thanks much..</description>
		<content:encoded><![CDATA[<p>Is there a way to query an entire sql server looking for a certain column? am trying to create an application where the users can search our entire sql server by a column name.I want the query to list the table name,database name,column name,column data type.<br />
Any ideas or sample code will be greatly appreciated.</p>
<p>Thanks much..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajpreeti</title>
		<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/#comment-45426</link>
		<dc:creator>Rajpreeti</dc:creator>
		<pubDate>Wed, 07 Jan 2009 09:43:39 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=587#comment-45426</guid>
		<description>Your articles are really very conducive to solve my problems.</description>
		<content:encoded><![CDATA[<p>Your articles are really very conducive to solve my problems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Find Table in Every Database of SQL Server - Part 3 Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/#comment-38607</link>
		<dc:creator>SQL SERVER - Find Table in Every Database of SQL Server - Part 3 Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Wed, 21 May 2008 04:20:58 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=587#comment-38607</guid>
		<description>[...] May 16, 2008 by pinaldave    Previously I wrote two articles about  SQL SERVER - Find Table in Every Database of SQL Server [...]</description>
		<content:encoded><![CDATA[<p>[...] May 16, 2008 by pinaldave    Previously I wrote two articles about  SQL SERVER &#8211; Find Table in Every Database of SQL Server [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/#comment-37973</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Tue, 13 May 2008 23:15:08 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=587#comment-37973</guid>
		<description>How about a query that writes queries?  Using sysdatabases table in the MASTER database you can write a query that looks for a table name in the sysobjects table in each database.  In my case I&#039;m looking for a &#039;Folders&#039; table.  

Running this query...

USE MASTER; SELECT &#039;USE &#039; + name + &#039;; SELECT &#039;&#039;&#039; + name + &#039;&#039;&#039; as DBName, name as TableName FROM sysobjects where name like &#039;&#039;Folders&#039;&#039;&#039; FROM sysdatabases WHERE dbid &gt; 5 ORDER BY dbid

You get these queries...

USE Northwind; SELECT &#039;Northwind&#039; as DBName, name as TableName FROM sysobjects where name like &#039;Folders&#039;
USE Q_SanJoaquin; SELECT &#039;Q_SanJoaquin&#039; as DBName, name as TableName FROM sysobjects where name like &#039;Folders&#039;
USE ClerkConv; SELECT &#039;ClerkConv&#039; as DBName, name as TableName FROM sysobjects where name like &#039;Folders&#039;
USE QuestysEnt; SELECT &#039;QuestysEnt&#039; as DBName, name as TableName FROM sysobjects where name like &#039;Folders&#039;
USE Q_Police; SELECT &#039;Q_Police&#039; as DBName, name as TableName FROM sysobjects where name like &#039;Folders&#039;

And running those queries, you get this....

DBName    TableName                                                                                                                        
--------- -------------------------------------------------------------------------------------------------------------------------------- 

(0 row(s) affected)

DBName       TableName                                                                                                                        
------------ -------------------------------------------------------------------------------------------------------------------------------- 
Q_SanJoaquin Folders

(1 row(s) affected)

DBName    TableName                                                                                                                        
--------- -------------------------------------------------------------------------------------------------------------------------------- 

(0 row(s) affected)

DBName     TableName                                                                                                                        
---------- -------------------------------------------------------------------------------------------------------------------------------- 
QuestysEnt Folders

(1 row(s) affected)

DBName   TableName                                                                                                                        
-------- -------------------------------------------------------------------------------------------------------------------------------- 
Q_Police Folders

(1 row(s) affected)</description>
		<content:encoded><![CDATA[<p>How about a query that writes queries?  Using sysdatabases table in the MASTER database you can write a query that looks for a table name in the sysobjects table in each database.  In my case I&#8217;m looking for a &#8216;Folders&#8217; table.  </p>
<p>Running this query&#8230;</p>
<p>USE MASTER; SELECT &#8216;USE &#8216; + name + &#8216;; SELECT &#8221;&#8217; + name + &#8221;&#8217; as DBName, name as TableName FROM sysobjects where name like &#8221;Folders&#8221;&#8217; FROM sysdatabases WHERE dbid &gt; 5 ORDER BY dbid</p>
<p>You get these queries&#8230;</p>
<p>USE Northwind; SELECT &#8216;Northwind&#8217; as DBName, name as TableName FROM sysobjects where name like &#8216;Folders&#8217;<br />
USE Q_SanJoaquin; SELECT &#8216;Q_SanJoaquin&#8217; as DBName, name as TableName FROM sysobjects where name like &#8216;Folders&#8217;<br />
USE ClerkConv; SELECT &#8216;ClerkConv&#8217; as DBName, name as TableName FROM sysobjects where name like &#8216;Folders&#8217;<br />
USE QuestysEnt; SELECT &#8216;QuestysEnt&#8217; as DBName, name as TableName FROM sysobjects where name like &#8216;Folders&#8217;<br />
USE Q_Police; SELECT &#8216;Q_Police&#8217; as DBName, name as TableName FROM sysobjects where name like &#8216;Folders&#8217;</p>
<p>And running those queries, you get this&#8230;.</p>
<p>DBName    TableName<br />
&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; </p>
<p>(0 row(s) affected)</p>
<p>DBName       TableName<br />
&#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Q_SanJoaquin Folders</p>
<p>(1 row(s) affected)</p>
<p>DBName    TableName<br />
&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; </p>
<p>(0 row(s) affected)</p>
<p>DBName     TableName<br />
&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
QuestysEnt Folders</p>
<p>(1 row(s) affected)</p>
<p>DBName   TableName<br />
&#8212;&#8212;&#8211; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Q_Police Folders</p>
<p>(1 row(s) affected)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Find Table in Every Database of SQL Server - Part 2 Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/#comment-37941</link>
		<dc:creator>SQL SERVER - Find Table in Every Database of SQL Server - Part 2 Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Tue, 13 May 2008 16:28:48 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=587#comment-37941</guid>
		<description>[...] 5, 2008 by pinaldave    Long time blog reader and SQL Server Expert Simon Worth has suggested two additional method to achieve same results as described in article SQL SERVER - [...]</description>
		<content:encoded><![CDATA[<p>[...] 5, 2008 by pinaldave    Long time blog reader and SQL Server Expert Simon Worth has suggested two additional method to achieve same results as described in article SQL SERVER &#8211; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon Worth</title>
		<link>http://blog.sqlauthority.com/2008/04/29/sql-server-find-table-in-every-database-of-sql-server/#comment-37340</link>
		<dc:creator>Simon Worth</dc:creator>
		<pubDate>Thu, 08 May 2008 21:06:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=587#comment-37340</guid>
		<description>Or you could built in functionality that SQL Server provides and use 1 line of code

sp_msforeachdb &quot;SELECT &#039;?&#039; DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE &#039;%address%&#039;&quot;

If you did indeed want to keep the results in a table you could do that too

CREATE TABLE #TableNameResults (DatabaseName VARCHAR(100) NOT NULL, TableName VARCHAR(100) NOT NULL)
INSERT INTO #TableNameResults EXEC sp_msforeachdb &quot;SELECT &#039;?&#039; DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE &#039;%address%&#039;&quot;

SELECT * FROM #TableNameResults

DROP TABLE #TableNameResults</description>
		<content:encoded><![CDATA[<p>Or you could built in functionality that SQL Server provides and use 1 line of code</p>
<p>sp_msforeachdb &#8220;SELECT &#8216;?&#8217; DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE &#8216;%address%&#8217;&#8221;</p>
<p>If you did indeed want to keep the results in a table you could do that too</p>
<p>CREATE TABLE #TableNameResults (DatabaseName VARCHAR(100) NOT NULL, TableName VARCHAR(100) NOT NULL)<br />
INSERT INTO #TableNameResults EXEC sp_msforeachdb &#8220;SELECT &#8216;?&#8217; DatabaseName, Name FROM ?.sys.Tables WHERE Name LIKE &#8216;%address%&#8217;&#8221;</p>
<p>SELECT * FROM #TableNameResults</p>
<p>DROP TABLE #TableNameResults</p>
]]></content:encoded>
	</item>
</channel>
</rss>
