1declare @SearchText nvarchar(max)='searchText'
2SELECT o.[name] as object_name
3 , sm.[definition]
4 FROM sys.sql_modules AS sm
5 JOIN sys.objects AS o
6 ON sm.object_id = o.object_id
7 JOIN sys.schemas AS ss
8 ON o.schema_id = ss.schema_id
9where sm.[definition] like '%'+@SearchText+'%'