the sp_depends
displays information about database object dependencies.
The following example lists the Procedures that depends on dbo.spSample_ProcedureName
EXEC sp_depends @objname = N'dbo.spSample_ProcedureName';
You can do some change on sp_depends
and extract what you needed.
I'd rather to edit my answer, because i think this is a useful question. So i wrote a full query to display the result. I've test this query and it was successful.
DECLARE @Res AS TABLE (SP_Names NVARCHAR(776), Dependencies NVARCHAR(MAX))
SELECT [name]
INTO #t_sp
FROM sys.procedures
WHILE EXISTS (SELECT [name] FROM #t_sp)
BEGIN
DECLARE @objname nvarchar(776) = (SELECT TOP(1) [name] FROM #t_sp)
declare @objid int -- the id of the object we want
declare @found_some bit -- flag for dependencies found
declare @dbname sysname
SELECT @dbname = parsename(@objname,3)
if @dbname is not null and @dbname <> db_name()
begin
raiserror(15250,-1,-1)
end
-- See if @objname exists.
select @objid = object_id(@objname)
if @objid is null
begin
select @dbname = db_name()
raiserror(15009,-1,-1,@objname,@dbname)
end
-- Now check for things that depend on the object.
if exists (select *
from sysdepends
where depid = @objid)
begin
raiserror(15460,-1,-1)
INSERT INTO @Res
(
SP_Names,
Dependencies
)
SELECT distinct 'name' = (s.name + '.' + o.name), @objname
--type = substring(v.name, 5, 66) -- spt_values.name is nvarchar(70)
from sys.objects o, master.dbo.spt_values v, sysdepends d,
sys.schemas s
where o.object_id = d.id
and o.type = substring(v.name,1,2) collate catalog_default and v.type = 'O9T'
and d.depid = @objid
and o.schema_id = s.schema_id
and deptype < 2
select @found_some = 1
end
DELETE #t_sp WHERE [name] = @objname
END
DROP TABLE #t_sp
SELECT * FROM @Res
ORDER BY SP_Names