How to search a text inside in SQL Server stored procedure?

This is quiet interesting question.this will help many of the developers to find the text which is included in Stored Procedure.It is very easy to search in side a stored procedures.Here I below explaining that,How to search a text inside in SQL Server stored procedure?  How to find text inside/with in SQL Server stored procedure?

DECLARE @Search varchar(255)
SET @Search='text_to_search'

SELECT DISTINCT
o.name AS Object_Name,o.type_desc
FROM sys.sql_modules s
INNER JOIN sys.objects o ON s.object_id=o.object_id
WHERE s.definition Like '%'+@Search+'%'
ORDER BY 2,1

Leave a Reply

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