Monday, March 12, 2012

Query to get name of views which reference a give column from a ta

Hi
Can somebody give me a query to find the name of all the views which referen
ce
a give column name of a table
ex: i want to find names of all views which have the column account_type
from the table accounts.
Thanks
RodgerRodger,
check view INFORMATION_SCHEMA.COLUMNS
Example:
use northwind
go
declare @.cn sysname
set @.cn = N'OrderID'
select TABLE_NAME
from INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME = @.cn and
objectproperty(object_id('[' + TABLE_SCHEMA + '].[' + TABLE_NAME + ']'),
'IsView') = 1
go
AMB
"Rodger" wrote:

> Hi
> Can somebody give me a query to find the name of all the views which refer
ence
> a give column name of a table
> ex: i want to find names of all views which have the column account_type
> from the table accounts.
> Thanks
> Rodger

No comments:

Post a Comment