Thursday, May 29, 2014

How to search a column name within all tables of a database?

Here is how we can get table name and column which you are looking for,

SELECT table_name,column_name FROM information_schema.columns
WHERE column_name like '%engine%'
-- OR ---
SELECT AS ColName, AS TableName
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE LIKE '%engine%'

Sample OUTPUT for one of the query,

ColName    TableName
EngineType    DSS_Setup