Friday, 13 May 2016

How to find the dependency of objects in SQL server ?

In SQL server we can find the dependency of objects using system stored procedure.

Syntax

SP_DEPENDS [DATABASE NAME].[SCHEMA NAME].OBJECTNAME

Example

SP_DEPENDS 'dbo.StudentDetail'

It will display the list of objects which depend on the studentdetail table.

Lets say we have use this object name [StudentDetail] in stored procedure or function or trigger.
If you want to find the list of objects which uses this table and those details will be displayed.

If there is no object dependency then the below message will appear.



In below screenshot I have created new stored procedure with studentdetail table.So if you run the object dependency of the table then the following stored procedure will appear.



Similarly I have created the function using the studentdetail table.

 Similarly I have created the trigger using the studentdetail table.


You can also pass the stored procedure name in Sp_Depends stored procedure.It will give list of objects and its columns depends on the stored procedure.



You can also pass the function name in Sp_Depends stored procedure.


You can also pass the trigger name in Sp_Depends stored procedure.


No comments:

Post a Comment