Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Scripting View Dependencies

Author  Topic 

R
Constraint Violating Yak Guru

328 Posts

Posted - 2011-06-28 : 07:17:05
If I right-click a table then choose View Dependencies, a dialog box opens with a really nice list showing appropriate tables and stored procedures.

As this data cannot be exported (correct me if I am wrong there!), is there a way to script the exact same results using a query?

I've searched for a solution and found methods that use PowerShell or multiple temporary tables, and even sp_depends (that only lists procedures). Is there a simpler way using table variables strictly in a query window to get the same data as the View Dependencies dialog shows?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-06-28 : 13:10:13
You can easily grab the code that SSMS used when you clicked the view dependencies option. Just launch SQL Profiler, then choose it in SSMS, then stop your trace and view the code. Voila!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

R
Constraint Violating Yak Guru

328 Posts

Posted - 2011-06-29 : 04:05:13
The Profiler shows the creation of temporary tables, which I was hoping to avoid. If I copy and paste the multiple transactions that Profile shows (865 lines) and run the query, it returns no results.
Go to Top of Page
   

- Advertisement -