DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Chris has posted 2 posts at DZone. View Full User Profile

SQL Server: Search Through Stored Procedures For Code

07.22.2007
| 4775 views |
  • submit to reddit
        This returns the names of stored procedures that contain the text you're looking for.

select so.name as 'storProc'
from sysobjects so
join syscomments sc
on so.id=sc.id
where so.type='P'
and sc.[text] like '%BIT_YOU_WANT_TO_FIND%' 

Say for example you're looking for all the stored procedures that mentioned the table 'user_table' - then just use this script and the all the stored procedures that make mention of this will be returned.