SQL Server with Mike250

Find text in Stored Procedures

I can't express how useful this has been to me when trying to find whether a text string exists in one of our Stored Procedures / Functions:

DECLARE @value VARCHAR(50) = 'getPrice'
SELECT DISTINCT o.name AS Object_Name, o.type_desc
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id = o.object_id
WHERE m.definition LIKE '%' + @value + '%'

Leave a reply