Quick way to search within a procedure in SQL Server

There are times when you want to to list out all the stored procedure names that contains certain keyword or search text.

Here’s a simple query that helps you do that.

Quick way to search within a procedure in SQL Server

SELECT OBJECT_NAME(ID) FROM SysComments 
WHERE Text LIKE '%<Search String>%' 
AND OBJECTPROPERTY(id, 'IsProcedure') = 1

Replace the <Search String> with the text that you want to search within all the stored procedures.

Here’s a query that retrieves all the stored procedures that contains the text employee.

SELECT OBJECT_NAME(ID) FROM SysComments 
WHERE Text LIKE '%Employee%' 
AND OBJECTPROPERTY(id, 'IsProcedure') = 1

image

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this blog post, let’s learn about the error message “1459 – An error occurred while accessing the database mirroring...
In this blog post, let’s learn about the error message “7937 – Columnstore index has one or more missing column...