Searching through stored procedures

  • I'm looking for an automated way to search through all of the stored procedures in a single database for a specified text string.  I'd like to be able to generate a list of all stored procedures which contain the text string.

  • Search in syscomments. A simple query

    select * from syscomments where text like '%mystring%'

    will get it for you. Surfinity also makes a great search engine for searching, but I'm not sure I'd use it on the system tables.

  • select so.name,

    from sysobjects so

    join syscomments sc

    on so.id = sc.id

    where sc.text like '% text to find %'

     

    This will give you the name of the object

     

  • You can also use the OBJECT_NAME() function as in:

    select OBJECT_NAME(id)

    FROM  syscomments

    where text like '% text to find %'


    Julian Kuiters
    juliankuiters.id.au

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply