Expand To Show Full Article
SQL Server 101 - Search tables for a specific column name

SQL Server 101 – Search tables for a specific column name

You might want to search all the tables in your database for a specific column name in order to rename or perform some cleanup.

How to search tables for a specific column name in SQL Server ?

SELECT      columns.name  AS 'Column Name'
            ,tables.name AS 'TableName'
FROM        sys.columns AS columns
JOIN        sys.tables  AS tables   ON columns.object_id = tables.object_id
WHERE       columns.name LIKE '%Id%'
ORDER BY    TableName
            ,columns.name;