dependency in multiple sp's
Is it possible to write a SQL query/procedure to identify a complete list of a stored procedures dependencies? I'm only interested in identifying other stored procedures and I'd prefer not to limit the depth of nesting that it gets too either. For example, if A calls B, which calls C, which calls D, I'd want B, C and D reported as dependencies for A
Bhuvanesh MohankumarPosted May 6, 2016, 3:42 AM
Hi Karthika,
Hope this will be helpful links for you,
o.type_desc AS referenced_object_type,
d1.referenced_entity_name,
d1.referenced_id,
STUFF( (SELECT ', ' + OBJECT_NAME(d2.referencing_id)
FROM sys.sql_expression_dependencies d2
WHERE d2.referenced_id = d1.referenced_id
ORDER BY OBJECT_NAME(d2.referencing_id)
FOR XML PATH('')), 1, 1, '') AS dependent_objects_list
FROM sys.sql_expression_dependencies d1 JOIN sys.objects o
ON d1.referenced_id = o.[object_id]
GROUP BY o.type_desc, d1.referenced_id, d1.referenced_entity_name
ORDER BY o.type_desc, d1.referenced_entity_name