WITH cte
AS
(
SELECT
source.name AS source,
target.name AS target,
CASE target.xtype
WHEN 'U' THEN 'Table'
WHEN 'P' THEN 'Store Procedure'
WHEN 'FN' THEN 'Function'
WHEN 'V' THEN 'View'
END AS type
FROM sysdepends d
INNER JOIN sysobjects source ON source.id = d.id
INNER JOIN sysobjects target ON target.id = d.depid
WHERE source.xtype = 'P' and source.name='PAYSP_EMPLOYEEUSERLOGINCHECK'
)
SELECT DISTINCT target, source, type
FROM cte
ORDER BY target, type DESC, sourceFind Out Table and Function Used in Procedure
