How do I find a stored procedure containing a certain text? While I understand that the best place to do this kind of searching is through your source control tool, but are there ways to do this in the database?
+2
A:
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE '%your text here%' AND ROUTINE_TYPE='PROCEDURE'
Russ Bradberry
2009-05-28 22:41:26
Whoa. Very useful. Thanks so much.
John Booty
2009-07-30 05:16:20
A:
You can search sys.sql_modules. Definition contains the text of procedures. The view contains procedures, views, udfs etc. To restrict yourself to stored procedures you should join with sys.procedure on object_id.
Remus Rusanu
2009-05-28 22:41:43