Thursday, July 24, 2008

Search for a keyword in stored procedures

Use either of the commands below to list all stored procedures that contain the given keyword.

SELECT ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%keyword%'
AND ROUTINE_TYPE='PROCEDURE'


SELECT OBJECT_NAME(id)
FROM syscomments
WHERE [text] LIKE '%keyword%'
AND OBJECTPROPERTY(id, 'IsProcedure') = 1
GROUP BY OBJECT_NAME(id)