Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Create stored procedure

Author  Topic 

new2this
Starting Member

16 Posts

Posted - 2008-05-06 : 16:34:58
Is there a way to create a stored procedure that accepts a column name and returns the name of the tables that have that column name?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-06 : 16:51:27
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'SomeColumn'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

new2this
Starting Member

16 Posts

Posted - 2008-05-06 : 16:53:40
Thanks - In the where statment, I forgot the _Name after Column.
Go to Top of Page
   

- Advertisement -