SQL Server , How to search for text in Stored Procedures

In this example, I searched for any SP containing the text LoadByIP:


 

SELECT Distinct SO.Name

FROM sysobjects SO (NOLOCK)

INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID

AND SO.Type = 'P'

AND SC.Text LIKE '%LoadByIP%'

ORDER BY SO.Name

 

 

Update: this was suggested by nts (see comments):

SELECT routine_name, routine_definition

FROM information_schema.routines

WHERE routine_definition LIKE '%LoadByIP%'

AND routine_type = 'PROCEDURE'

Both work well :-)

posted @ Wednesday, September 16, 2009 2:32 PM

Print

Comments on this entry:

# re: SQL Server , How to search for text in Stored Procedures

Left by nts at 9/18/2009 1:03 PM
Gravatar
nice will test this later, i use :- SELECT routine_name, routine_definition
FROM information_schema.routines
WHERE routine_definition LIKE '%textyoursearchingfor%'
AND routine_type = 'PROCEDURE'

# To:nts

Left by Angel Eyes at 9/21/2009 8:01 AM
Gravatar
Nice, I like it. I'm going to add it to this post :-)

Your comment:



 (will not be displayed)


 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345