Monday, 19 April 2010

Get Name of Stored Procedures by Passing Table Name

DECLARE @TABLENAME VARCHAR(50)
SET @TABLENAME='<TableName>' --Pass the Table Name here
SELECT @TableName as [Table Name],A.Name AS [SP Name],B.Text as [SP Text]
from SYSOBJECTS A
INNER JOIN SYSCOMMENTS B
ON A.ID=B.ID
WHERE B.TEXT LIKE '%'+@TableName+'%'
and A.TYPE='P'

No comments: