Displays information about database object dependencies (for example, the views and procedures that depend on a table or view, and the tables and views that are depended on by the view or procedure). References to objects outside the current database are not reported.
sp_depends [@objname =] 'object'
0 (success) or 1 (failure)
sp_depends displays two result sets.
This result set shows the objects on which object depends.
Column name | Data type | Description |
---|---|---|
name | nvarchar(40) | Name of the item for which a dependency exists |
type | nvarchar(16) | Type of the item |
updated | nvarchar(7) | Whether the item is updated |
selected | nvarchar(8) | Whether the item is used in a SELECT statement |
column | sysname | Column or parameter on which the dependency exists |
This result set shows the objects that depend on object.
Column name | Data type | Description |
---|---|---|
name | nvarchar(40) | Name of the item for which a dependency exists |
type | nvarchar(16) | Type of the item |
An object that references another object is considered dependent on that object. sp_depends determines the dependencies by looking at the sysdepends table.
Execute permissions default to the public role.
This example lists the database objects that depend on the Customers table.
USE Northwind
EXEC sp_depends 'Customers'
CREATE PROCEDURE | EXECUTE |
CREATE TABLE | sp_help |
CREATE VIEW | System Stored Procedures |