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


Answer this question

List of tables in use by a view

  • Qwavel

    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



  • Mathieu Descorbeth

    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



  • haus_baus

    I would like to do it inside VB.NET or C# using the SMO
  • List of tables in use by a view