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

Comments

Popular posts from this blog

Top 5 AI Tools Every Developer Should Use to Boost Coding Efficiency

How To Generate Random Dates Between Two Date Range in SQL Server

Find the number of columns in a table