Tuesday, February 05, 2008

Search for Stored Procedure Containing Text

Today I was working on some inherited code and found myself wondering what a particular database field meant. I tried searching the application's code, but being a good little programmer the previous developer had used stored procedures for all the database calls. So off I went to internetland to find how to find a stored procedure containing specific text. Here's what I found:
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%myField%'
AND ROUTINE_TYPE='PROCEDURE'

Just replace myField with whatever your field is called, or (to be more specific) whatever text you're trying to find in the stored procedure. I'm using this on SQL Server 2005, but judging from the query it should be fairly universal.

Labels: , ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Blog Home