HomeSQL ServerSQL 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;

Leave a Reply

You May Also Like

When dealing with a relational database management system (RDBMS) like SQL Server, compatibility level is an important concept to understand....
In this blog post, let’s learn about the error message “49975 – Unable to load controller client certificate due to...
In this blog post, let’s learn about the error message “49973 – Cannot remove tempdb remote file to local tempdb...