SQL Server Dependencies

Hopefully I’m not too late with this:

If your SQL Login has access to the sys schema in a particular database, you can use the sys.dependencies view to find all of an object’s dependencies in one shot:

SELECT o.name, o.type_desc, p.name, p.type_desc
FROM sys.sql_dependencies d
INNER JOIN sys.objects o
    ON d.object_id = o.object_id
INNER JOIN sys.objects p
    ON d.referenced_major_id = p.object_id

Using this as a starting point you could probably build a decent tool to create a dependency tree. There are also type specific views (e.g. sys.columns) that give more in depth information regarding each specific database object type; these could be used to provide contextual information on an object if necessary.

Leave a Comment