List of Tables and Functions used in Stored Procedure

Kirthiga
Posted by Kirthiga under Sql Server category on | Points: 40 | Views : 848
;WITH SP AS (
SELECT p.name AS [Procedure Name], t.name AS [Table & Function Name]
,ROW_NUMBER() OVER(partition by p.name,t.name ORDER BY p.name,t.name) AS row
FROM sysdepends d
INNER JOIN sysobjects p ON p.id=d.id
INNER JOIN sysobjects t ON t.id=d.depid
WHERE p.xtype = 'P'
)SELECT [Procedure Name], [Table & Function Name] FROM SP WHERE row = 1
ORDER BY [Procedure Name],[Table & Function Name]

Comments or Responses

Login to post response