Wednesday, February 17, 2010

How to find a string in a stored procedure?

In addition to a previous post - this might be helpfull to some sclerotic (ha-ha)  persons as me:

Finding a string in some stored procedure. You remember the code, you remember that you have written it (well a year ago), but where the hell is it?

Ok, here is the code:

By replacing string between percent signs - to your string (Pay Attention: this doesn't work on substrings, strings only!) - returns a collection of stored procedures where that string resides.

SELECT

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

Read more: Yonathan Masovich

Posted via email from jasper22's posterous