Technical Article

Views created per table

,

A little code for the procedure to collect all views together with schema info to see how many views there are using the data from one table!

Short code, one input parameter and that's all you will have the results!

/*
You can create it in everywhere in your databases to see all views that you 
created for any table so the proc has one parameter where you will put the 
table name during execution of this procedure!
*/
--For testing results we are using the ADVENTUREWORKS database
USE ADVENTUREWORKS;
GO

--Creating the procedure:
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

--Testing the procedure
EXEC VIEWS_IN_TABLE
ADDRESS;
GO

Rate

5 (5)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (5)

You rated this post out of 5. Change rating