How to find all views created on a particular table?

  • Hi,

    I have a table and i want to know sql query which will return all the views created on that table.

    Thankd in advance.

  • Hi Ruchi,

    The following stored procedure will help you in finding all the related views created on a given table.

    Use ‘databasename’

    sp_depends 'tablename'

    This would provide the complete dependencies on the table(foreign key references, etc), however in this context we are interested only on views. Hence you need to check out for the type 'view'

    Let me know if this helps...else we can look out for some other options.

    -Rajini

  • Thanks a lot, this has solved my problem...

  • Hello,

    For the record, it is worth noting that sp_depends only returns references to objects within the current DB i.e. if there are Views in other DBs based on the table, then they won't be reported.

    Regards,

    John Marsh

    www.sql.lu
    SQL Server Luxembourg User Group

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply