Searching for Text in Stored Procedures

  • Hello,

    I have been trying to find a way to search for a certain string within all stored procedures in a database. After a seach on this site I found quite a few. Thanks, this helped.

    My question. No matter which method I try I get proper results for "[Database].[dbo]" but no results for "[Database].[dbo]." I am wondering why this might be as I am actually looking for "[Database].[dbo].[tblSpecificTable]".

    Thank you in advance for your help,

    Chuck

  • What did you try?

    Does this work?

    Select object_name(id) from dbo.SysComments where text like '%[Database].[dbo].[tblSpecificTable]%'

  • BOL: LIKE

    ...

    Symbol      Meaning

    LIKE '[[]'    [

    LIKE ']'      ]

    ...

    Check collation on your server, may be is case-sensitive and try this:

    select object_name(id) from dbo.syscomments where text like '%[[]Database].[[]dbo].[[]tblSpecificTable]%'

  • Thank you for the help everyone.

    The '[[]' works great. It just didn't occur to me to look at the '[' and ']' as they were inside the quote marks.

    Thank you again.

    Chuck

  • Brackets are a special character... look up quotename('some string') and see what the function returns .

  • Just wanted to mention that you might want to try the Free SQL Server Add-on Tool called SQL Digger (http://sqldigger.bdsweb.be/).  This tool is great and easy to use.  You can also search through multiple databases at once.

    ----------------------------------------------------------01010011010100010100110000100000010100110110010101110010011101100110010101110010001000000101001001101111011000110110101101110011

Viewing 6 posts - 1 through 5 (of 5 total)

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