Home > DataBases, MSSQL > Find that Stored Procedure

Find that Stored Procedure

We have all these stored procedures that send DB mail and I always struggle to remember how to find that little line of text that the client wants to change so I keep going to this site: http://stackoverflow.com/questions/5079457/how-do-i-find-a-stored-procedure-containing-text after a quick google search. Here’s my personal copy of this solution so that I can find it and use it more swiftly:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE ‘%828%’
AND ROUTINE_TYPE=’PROCEDURE’

Hope it helps!
{9/12/2012} Go a step further and simpler:

SELECT o.name As [Views]
FROM SYSOBJECTS o INNER JOIN SYSCOMMENTS c

ON o.id = c.id
WHERE c.text LIKE ‘%941%’

Categories: DataBases, MSSQL
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment