Finding dependent procedure of every procedure :
ALTER FUNCTION dependency (@name varchar(200))
RETURNS TABLE
AS
RETURN
SELECT
OBJECT_NAME(object_id) objectname
FROM sys.sql_modules
WHERE definition LIKE '%' + @name + '%'
AND OBJECT_NAME(object_id) <> @name
GO
SELECT
sp.name,
d.objectname AS dependentSP
FROM sys.procedures sp
CROSS APPLY dbo.dependency(sp.name) AS d
ORDER BY 1
GO
No comments:
Post a Comment