Check for database objects that depend on the stored procedure.
DECLARE
@sp NVARCHAR(1000)
SET @sp = N'dbo.uspTest01'
-- Objects that depends on [@sp]
SELECT
referencing_schema_name,
referencing_entity_name
FROM sys.dm_sql_referencing_entities(@sp, 'OBJECT')
-- Objects on which [@sp] depends
-- Will throw an error if the object no longer exist.
SELECT
referenced_schema_name,
referenced_entity_name
FROM sys.dm_sql_referenced_entities(@sp, 'OBJECT')
SELECT
referenced_schema_name,
referenced_entity_name
FROM sys.sql_expression_dependencies
WHERE referencing_id = OBJECT_ID(@sp)
Comments