Sometimes you need to find out in which tables a certain column name exists. For example when you want to find out where it’s being used as a foreign key. Here’s a handy script to use in T-SQL.
SELECT OBJECT_NAME(object_id), * FROM sys.columns WHERE name = 'columnname'
This makes use of the
OBJECT_NAME function in T-SQL which according to the documentation:
Returns the database object name for schema-scoped objects.
Grz, Kris.