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
 Looking for all tables with a specific field

Author  Topic 

Aleph_0
Yak Posting Veteran

79 Posts

Posted - 2011-07-12 : 17:31:12
Hi all, is there a way I can get a list of all tables that have, for example, the field [acctID]? There's gotta be an easier way than manually searching through each table in the database!

Thanks!

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-07-12 : 17:45:17
SELECT Table_Name FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME='AcctID'
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-07-12 : 17:47:00
Much easier way!

SELECT * from INFORMATION_SCHEMA.COLUMNS
WHERE column_name = 'acct_id'

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

Aleph_0
Yak Posting Veteran

79 Posts

Posted - 2011-07-12 : 18:02:24
You guys rock. I've got to learn more about INFORMATION_SCHEMA. Thanks again!
Go to Top of Page
   

- Advertisement -