Don’t Use sp_depends in SQL Server (it’s Deprecated)

SQL Server has a system stored procedure called sp_depends that returns information about dependencies between objects within the current database.

Microsoft has marked this stored procedure as deprecated, which means that it’s in maintenance mode and may be removed in a future version of SQL Server. You should avoid using sp_depends in new development work, and you should modify applications that currently use it to use either sys.dm_sql_referencing_entities() or sys.dm_sql_referenced_entities() instead (depending on whether you need referencing entities, or referenced entities to be returned.

The sys.dm_sql_referencing_entities() system dynamic management function returns a list of entities that depend on the given entity. More specifically, it returns all entities in the current database that reference another user-defined entity by name.

The sys.dm_sql_referenced_entities() system dynamic management function, on the other hand, returns a list of all user-defined entities that a specific entity depends on. More specifically, it returns all user-defined entities that are referenced by name, in the definition of a given entity. You can use this function for cross-database and cross-server entities.

Not Sure if You’re Currently Using sp_depends?

If you’re not sure whether your system uses sp_depends, you could always use sys.dm_os_performance_counters to find out. You can use this system dynamic management view to return a count of how many times each deprecated feature has been encountered since SQL Server was started. Check out Quickest Way to Find Deprecated Features Still Being Used in a SQL Server Instance for more info and examples.

A more elaborate method is to use extended events to create a log file that contains extra information about each usage of the deprecated feature. For example, you can record info such as the SQL statement that contains the deprecated feature, the user who ran it, the time it was run, the database it was in, and more. See Using Extended Events to Log Deprecated Features Being Used in a SQL Server Instance for step by step instructions on how to do that.

Microsoft Documentation Reference