Sql Server : Finding all the views  with table name as paramenter and column name as parameter

N_Sri
N_Sri used Ask the Experts™
on
Hi ,
Please help me to write this query.
Query  which takes  Table name as parameter AND Column name as parameter ,and finds all the views in my database
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
SELECT OBJECT_NAME(object_id)
FROM sys.sql_modules
WHERE OBJECTPROPERTY(object_id, 'IsView') = 1
Commented:
Hi,
  Please try this,

DECLARE @TABLENAME VARCHAR(255)
DECLARE @COLUMNNAME VARCHAR(255)
SET @TABLENAME='TABLE NAME YOU WANT'
SET @COLUMNNAME='COLUMN NAME'
select * from INFORMATION_SCHEMA.VIEW_COLUMN_USAGE	WHERE TABLE_NAME=@TABLENAME AND COLUMN_NAME=@COLUMNNAME

Open in new window

Author

Commented:
thankyou

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial