Script to Search a specific column from the entire database
Often databases are complexly designed and consists of many tables. Searching for a specific column can be a tedious job if we do not know the table name where the column resides.
If you are in a situation where you are searching for a specific column and do not know which table to look at for it, use below code to find the table name quickly:
If you do not know complete column name:
use [Database]
SELECT name FROM sysobjects
WHERE id IN ( SELECT id FROM syscolumns WHERE name like '[%ColumnName%]' )
If you know complete column name:
use [Database]
SELECT name FROM sysobjects
WHERE id IN ( SELECT id FROM syscolumns WHERE name = '[ColumnName]' )
Comments