Subscribe to our YouTube Channel for more Videos

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;
Senthil Kumar B
Senthil Kumar is a former Microsoft MVP (Most Valuable Professional). He is a Co-Author of the book "Windows 10 Development Recipes using JavaScript and CSS" for Apress Publication. He is a technical presenter, blogger, mentor and a Geek.  Senthil is a regular speaker is various local user groups. He has presented at conferences like Great Indian Developer Summit (GIDS) & Microsoft DevCamps. You can reach out to him via his Twitter handle @isenthil.