Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Count all views where column exists

Author  Topic 

aharvestofhealth
Yak Posting Veteran

52 Posts

Posted - 2011-04-23 : 11:03:44
I have a column (PRC_1) that I want to find in which views it appears. I was able to find where that specific column existed within my tables by running the following:

SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE 'prc_1'
ORDER BY schema_name, table_name;


But I also want to see it for me views as well. Any suggestions?

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-23 : 12:01:11
I think INFORMATION_SCHEMA.VIEW_COLUMN_USAGE returns this information.
Go to Top of Page
   

- Advertisement -