Find all tables and views containing column with specified name
Many of us some times wants to know that where a specific column is located as reference to other tables or views.
If this is the case for you, then you can execute the following query:
Just replace the YourColumnName with your desired column name.
SELECT COLUMN_NAME AS 'ColumnName' ,
TABLE_NAME AS 'TableName'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%YourColumnName%'
ORDER BY TableName , ColumnName;
Please note that, if you follow the convention to place every where with same column name, then it will brings good output result for you.
Thanks
If this is the case for you, then you can execute the following query:
Just replace the YourColumnName with your desired column name.
SELECT COLUMN_NAME AS 'ColumnName' ,
TABLE_NAME AS 'TableName'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%YourColumnName%'
ORDER BY TableName , ColumnName;
Please note that, if you follow the convention to place every where with same column name, then it will brings good output result for you.
Thanks
Comments
Post a Comment