Wednesday, April 2, 2014

Finding the DB name and Table name based on coloumn from whole instance

Below script helps you to find the DB name, Table when you know only column name and not sure about database and table name.

exec sp_msforeachdb 'select TABLE_CATALOG as DBName,TABLE_NAME,COLUMN_NAME
from [?].INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME= ''Column Name'';'

No comments:

Post a Comment