sp_depends

Transact-SQL Reference

Transact-SQL Reference

sp_depends

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.

Syntax

sp_depends [ @objname = ] 'object'

Arguments

[@objname =] 'object'

The database object to examine for dependencies. The object can be a table, view, stored procedure, or trigger. object is nvarchar(776), with no default.

Return Code Values

0 (success) or 1 (failure)

Result Sets

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.

Remarks

An object that references another object is considered dependent on that object. sp_depends determines the dependencies by looking at the sysdepends table.

Permissions

Execute permissions default to the public role.

Examples

This example lists the database objects that depend on the Customers table.

USE Northwind
EXEC sp_depends 'Customers'

See Also

CREATE PROCEDURE

CREATE TABLE

CREATE VIEW

EXECUTE

sp_help

System Stored Procedures