Find all views created on a table

USE ADVENTUREWORKS; — You can use any kind of database that you have
GO

–Procedure that shows all views created on a table, together with schema

CREATE PROCEDURE VIEWS_IN_TABLE
@TABLENAME
VARCHAR(200)
AS
SELECT
VIEW_SCHEMA, VIEW_NAME FROM INFORMATION_SCHEMA.VIEW_TABLE_USAGE
WHERE TABLE_NAME = @TABLENAME;
GO

–executing the procedure with parameter value
EXEC VIEWS_IN_TABLE
ADDRESS

–n’joy the results!–Dugi

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s