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
 General SQL Server Forums
 New to SQL Server Programming
 how can I search a schema to identify table

Author  Topic 

Prestidigitator
Starting Member

16 Posts

Posted - 2007-02-12 : 17:49:31
I am trying to find a needle in a haystack.

One of the tables in this database has a column named column_xyz.

There are over 800 tables, each with numerous columns. If I know that the column I am looking for is "column_xyz" is there an easy query I can do to identify all tables that contain that column?

I hope.

Thanks

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-02-12 : 17:53:40
select * from information_schema.columns
where column_name = 'column_xyz'
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-02-12 : 17:53:44
You can query the INFORMATION_SCHEMA.COLUMNS view.



CODO ERGO SUM
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-02-12 : 17:54:50
select * from INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME='column_xyz'

wow, double snipe!

www.elsasoft.org
Go to Top of Page

Prestidigitator
Starting Member

16 Posts

Posted - 2007-02-12 : 18:34:51
Thanks - That will help bunches.
Go to Top of Page
   

- Advertisement -