Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Object dependencies in xml format

By Peter Sloboda,

Since we have sys.dm_sql_referenced_entities, dynamic view, which contains the dependency tree, I gave it a try and used it to display all objects in xml format.
The stored procedure uses the view to retrieve the hierarchy, stores it in a table (#tree) which is later traversed using recursive CTE.
Just create the stored procedure, pass it an object name and expand the xml result.
I didn't include check for the level of recursion, but we all know that it'll break if the depth reaches 32. I don't mean to preach, but if any of your sql objects have dependency that deep, you're in trouble.

Total article views: 848 | Views in the last 30 days: 3
 
Related Articles
FORUM

How to pass an object to stored procedure?

How to pass an object to stored procedure?

FORUM

How to find the objects that use a stored procedure

How to find the objects that use a stored procedure

FORUM

find all the objects in a stored procedure

find out all database objects used in a stored procdure

FORUM

dynamic object(database/schema/obj) in stored procedure

how to reference multiple database/objects in stored procedure (parameterization)

FORUM

SP resultset to store in two object variables

SP resultset to store in two object variables

Tags
object dependencies    
xml    
 
Contribute