LLI Wiki — My Digital Knowledge Base

Search for text in stored procedures and functions

Query that searches the definitions of stored procedures and functions for a text string, using INFORMATION_SCHEMA.ROUTINES.

To find the stored procedures and functions of the current database whose definition contains a given text, search INFORMATION_SCHEMA.ROUTINES.

DECLARE @search VARCHAR(50)

SET @search = 'searchterm'

SELECT
    ROUTINE_NAME,
    ROUTINE_DEFINITION
FROM
    INFORMATION_SCHEMA.ROUTINES
WHERE
    ROUTINE_DEFINITION LIKE @search
ORDER BY
    ROUTINE_NAME

Notes

Mastodon LLIMastodon SocialFosstodon