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

The Power of .NET Core Caching: Best Practices for Optimal Performance

Custom Function string_split for SQL Server 2008R2 (T-SQL split string)

Find the number of columns in a table