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;
Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Hey, wait!Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.