Friday, August 8, 2008

SQL Server Object Dependencies

Paul Montgomery was kind enough to pass this one on. This is great for seeing what function or stored procedure is used by.


SELECT DISTINCT
o.name AS UsedBy
FROM Sys.sysdepends j
JOIN sys.objects o on o.object_id = j.id
JOIN sys.objects d on d.object_id = j.depid
WHERE d.name = 'MyFunctionOrStoredProcedureName'

3 comments:

Dan Shultz said...

Right click on the procedure... View Dependencies in Mgt Studio works too.

Greg Finzer said...

Thanks Dan. I needed the text version because I am pasting the results into Word for research purposes.

sqlblindman said...

Be aware that neither of these methods will catch references embedded in dynamic SQL.
- blindman