Technical Article

Search All Stored Procedures in a Database

,

Sometimes there comes a situation when we need search for a text in all the procedures in the current database. This SQL script does it. It searches for the search text in all the stored procedures and gives you back the name of the stored procedures.

declare @searchString varchar(100)

Set @searchString = '%' + 'DtgSchemaOBJECT' + '%'

 SELECT Distinct SO.Name
 FROM sysobjects SO (NOLOCK)
 INNER JOIN syscomments SC (NOLOCK) on SO.Id = SC.ID
 AND SO.Type = 'P'
 AND SC.Text LIKE @searchString
 ORDER BY SO.Name

Rate

3.56 (16)

You rated this post out of 5. Change rating

Share

Share

Rate

3.56 (16)

You rated this post out of 5. Change rating