In SQL Server, how do you query the database to return all tables that have a field with a specific name?
The following query returns a unique list of tables where Column_Nameis equal to the column you are looking for:
Column_Name
SELECT Table_Name FROM INFORMATION_SCHEMA.COLUMNS WHERE Column_Name = 'Desired_Column_Name' GROUP BY Table_Name
SELECT Table_Name FROM Information_Schema.Columns WHERE Column_Name = 'YourFieldName'
I am an old school:
SELECT DISTINCT object_name(id) FROM syscolumns WHERE name = 'FIELDNAME'