Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Views created per table Expand / Collapse
Author
Message
Posted Wednesday, July 16, 2008 11:16 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, April 02, 2013 1:48 AM
Points: 1,252, Visits: 3,367
Comments posted to this topic are about the item Views created per table

============================================================
SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #535673
Posted Wednesday, September 17, 2008 2:18 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, February 28, 2013 1:54 AM
Points: 1,325, Visits: 1,376
Hello,

Thanks for the script.

An interesting experiment, but unless there were hundreds of Views in a DB, I think I would prefer using a straight select e.g. Select * From INFORMATION_SCHEMA.VIEW_TABLE_USAGE Order By TABLE_NAME, VIEW_NAME

Regards,

John Marsh


www.sql.lu
SQL Server Luxembourg User Group
Post #570809
Posted Wednesday, September 17, 2008 4:43 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, August 23, 2010 8:30 AM
Points: 229, Visits: 146
Hi,

At first I thought the query was really good - it would need a tweak to make it a bit better where you have nested views - so something like this:

with Table_analysis (View_Name , level )
as (
select view_name, 0 as level
from information_schema.view_table_usage
where table_name = @Table_Name
union all
select vtu.view_name, level + 1 as level
from information_schema.view_table_usage vtu
inner join Table_analysis ta
on ta.View_Name = vtu.table_name
)
select * from Table_analysis
order by view_name
go

unfortunately the results of this don't match up with the Red Gate Dependency checker which found an additional 10 or so views for one of our tables within the same database. After manually checking the differences I found that the nested views should have been included in both lists but sadly the view_table_usage didn't contain all the information it should.

A bit disappointing really - this could have been a really good technique to get view information - instead we have to use Red Gate dependency checker to work out what views access a certain table when we are making DDL changes to tables

Sorry for sounding like a salesman of Red Gate - but using this view_table_usage data doesn't work for us.

Tony
Post #570895
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse