SQL: How to Find Text in Stored Procedures

Searching for Text in a SQL Stored Procedure

I always write a blog article on things that took me a little to time to find when I working on various projects.

I’m working a project with another developer and they had sent me a screenshot of a SQL stored procedure that I needed to look at but they didn’t tell me the name of the file.

I needed to take some text from the screenshot and figure out which stored procedure it was in out of 100 or more.

Below is an example of the SQL script I used to find the text I was looking for. You’ll be searching the definition for you specific text.

SQL Script Example:
Find Text in Stored Procedures

SELECT DISTINCT
       o.name AS Object_Name,
       o.type_desc,
	   m.definition
FROM sys.sql_modules m
       INNER JOIN
       sys.objects o
         ON m.object_id = o.object_id
WHERE m.definition Like '%@RowString%';

I hope this help you solve your issue!

~Cyber Abyss

Author: Rick Cable / AKA Cyber Abyss

A 16 year US Navy Veteran with 25+ years experience in various IT Roles in the US Navy, Startups and Healthcare. Founder of FinditClassifieds.com in 1997 to present and co-founder of Sports Card Collector Software startup, LK2 Software 1999-2002. For last 7 years working as a full-stack developer supporting multiple agile teams and products in a large healthcare organization. Part-time Cyber Researcher, Aspiring Hacker, Lock Picker and OSINT enthusiast.