Search for Column Name in All Tables in All Databases

Use a text wild card to search for a column name in all tables in each database.  Stored procedure sp_msforeachdb is used to cycle through each database.  The sys tables are used to obtain table and column information.  The output will include Database Name, Schema Name, Table Name, Column Name, and code to easily select the top 10 from a table returned in the result.

Leave a Reply

Your email address will not be published. Required fields are marked *