Monday, March 12, 2012

List of tables in use by a view

Hi,

I wonder if I can list the tables (and views) used inside a view, I mean the list of tables in the FROM clause

Thanks,

Arty

An easy way is to call the "sp_depends @.objname" stored procedure. Within Management Studio, you can also right-click on an object and choose "View Dependencies"

Peter

|||I would like to do it inside VB.NET or C# using the SMO|||One way is to use SMO like:

Database db = srv.Databases["test"];

string a = "sp_depends " + objname;

db.ExecuteWithResults(a);
There are other ways of using SMO to get the dependency information, but I do not have the code available.

Peter

No comments:

Post a Comment