HomeSQL ServerQuick way to search within a procedure in SQL Server

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

You May Also Like

When dealing with a relational database management system (RDBMS) like SQL Server, compatibility level is an important concept to understand....
In this blog post, let’s learn about the error message “49975 – Unable to load controller client certificate due to...
In this blog post, let’s learn about the error message “49973 – Cannot remove tempdb remote file to local tempdb...