user6576015 user6576015 - 4 months ago 28
SQL Question

SQL SERVER 2008 - SELECT query

I have a database with over a 150 tables. I need to be able to find every table that has a field name called EmployeeID. Is there a way for me to find all tables that have this field name? It's kind of a long process if I go through each table and try to find if it has that field?

Answer

Use INFORMATION_SCHEMA.COLUMNS:

select c.*
from INFORMATION_SCHEMA.COLUMNS c
where column_name = 'EmployeeID';