Find column in Sql Server database

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.

Get list of all tables in the MS SQL Server database that contains a column with a given name.


SELECT AS ColName, AS TableName
FROM sys.columns c
    JOIN sys.tables t ON c.object_id = t.object_id
WHERE LIKE '%MyColumnName%'
Print Friendly, PDF & Email

Comments are closed.