While analyzing or debugging an application, you surely already had to search for a certain column, or field, referring to a database. The common task is to find all the tables, having that exact column name, to which the code is pointing to. If you’ll search for it manually throughout a large database, you risk to miss some important tables.
The following example will make your job much easier.
Goal:
Get list of all tables in the MS SQL Server database that contains a column with a given name.
Solution:
SELECT c.name AS ColName, t.name AS TableName FROM sys.columns c JOIN sys.tables t ON c.object_id = t.object_id WHERE c.name LIKE '%MyColumnName%'