February 9, 2012

To Find Dependent Objects in SQL Server

We can find all dependent objects on a particular object in SQL Server.
Let’s suppose we have two stored procedures as below:

CREATE PROCEDURE spA
AS
BEGIN

    SELECT GETDATE()
END

CREATE
PROCEDURE spB
AS
BEGIN

    EXEC spA
END

SELECT * FROM sys.dm_sql_referencing_entities('dbo.spA','Object')

Below query will give list of objects those are using spA stored procedure.

That’s It.
Enjoy Learning.

No comments:

Post a Comment