SQL Find all procedures that contains a specific text

Monday, 29 June 2009 09:59 by myro

Let's says you need to find out all the stored procedures that reference a column or that just contains a text. You can use:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION 
    FROM INFORMATION_SCHEMA.ROUTINES 
    WHERE ROUTINE_DEFINITION LIKE '%foobar%' 
    AND ROUTINE_TYPE='PROCEDURE'

Things get simplier if you are in SQL Server 2005; start a new query and paste this:

SELECT Name 
    FROM sys.procedures 
    WHERE OBJECT_DEFINITION(object_id) LIKE '%foobar%' 

Reference: http://databases.aspfaq.com/database/how-do-i-find-a-stored-procedure-containing-text.html

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Sql
Actions:   Bookmark and Share | Permalink | Comments (1) | Comment RSSRSS comment feed
If you consider this post usefull for your purposes, please consider visiting my sponsors to help me out with the myrocode.com maintenance. Thank you.

Comments