Click here to Skip to main content
13,503,224 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 15 Mar 2012

Searching within all the Stored Procedures in a database

, 15 Mar 2012
Rate this:
Please Sign up or sign in to vote.
You can search for any string with in the TSQL scripts of all the Stored Procedures in a database using the syscomments table.


Sometimes we may want to find out which procedure updates a particular column to a given status, which all procedures are joining two given tables etc. If we can search with in the stored procedure text it will enable us to isolate the problem and rectify bugs faster.

Using the code

Just query the syscomments table that stores all the TSQL scripts of the procedures. The below query also joins sys.objects also to find out the created and last modified time of the stored procedures.

SELECT ProcedureName, TEXT
, so.create_date [Created Date]
, so.modify_date [Modified Date]
FROM SysComments sc
JOIN Sys.Objects so ON OBJECT_NAME( =
WHERE Text LIKE '%Sample%'

Note that this script works only with SQL Server


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Saral S Stalin
Technical Lead
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 3 Pin
praveendubey1726-Mar-14 22:03
memberpraveendubey1726-Mar-14 22:03 
QuestionThanks, but... Pin
VMAtm19-Mar-12 1:59
memberVMAtm19-Mar-12 1:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180417.1 | Last Updated 15 Mar 2012
Article Copyright 2012 by Saral S Stalin
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid