Pages

Tuesday, December 11, 2012

Finding Occurrences of a Word in MSSQL Stored Procedures

0 comments

Here's a little trick that slipped my mind until I needed to search through about 2400 SPs looking for a specific word.
The query is very simple, and it returns a listing of all of the SPs with the word you're looking for.
It's just another one of those 'you don't know what you've forgotten until you need it' things.
SELECT ROUTINE_NAME, ROUTINE_DEFINITION 
    FROM INFORMATION_SCHEMA.ROUTINES 
    WHERE ROUTINE_DEFINITION LIKE '%foobar%' 
    AND ROUTINE_TYPE='PROCEDURE'

Leave a Reply

Labels