Identifying object dependencies in SQL Server using SP_DEPENDS

Introduction

When developing components for SQL Server one change may affect another database object.  Finding these dependent objects should be straightforward, but in most cases it is not as easy as we would think. There are several methods of getting this information, in this article we will have a look using SP_DEPENDS a System Stored Procedure.

Syntax

exec sp_depends [ @objname = ] '<object>' 

The sp_depends  shows the following result set of the object depend on <object>.

Column nameData typeDescription
namenvarchar(257 )Name of the item for which a dependency exists.
typenvarchar(16)Type of the item.

Example

exec [sp_depends] @objname = N'[Details].[StudentPersonalDetails]';
Fig.1 Result set for the example table object

Conclusion

By using SP_DEPENDS system stored procedure, we can view all the object dependencies. This is also one of the approach to find the object dependencies. I assume this tip was very useful. Please share your feedback in the comment section.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Built with WordPress.com.

Up ↑

%d bloggers like this: