Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Search for specific text in all stored procedures (See related posts)

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

Comments on this post

darickard posts on Apr 26, 2007 at 11:59
Seems to work better if you wildcard the search term as shown below. That could also be done when setting the @search variable, but if you do it in the query you don't have to worry about it anymore.

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

You need to create an account or log in to post comments to this site.


Click here to browse all 4861 code snippets

Related Posts