Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 716 | Views in the last 30 days: 37
 
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

SP resultset to store in two object variables

SP resultset to store in two object variables

FORUM

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

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

Tags
object dependencies    
xml    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones