This will work on SQL Server 2005 and later.Since the code is building an XML string, keywords overlapping the magic 4000 character limit are fetched!SELECT p.RoutineName, 'EXEC sp_helptext ' + QUOTENAME(p.RoutineName) AS [Exec] FROM ( SELECT OBJECT_NAME(so.ID) AS RoutineName, (SELECT TOP 100 PERCENT '' + sc.TEXT FROM SYSCOMMENTS AS sc WHERE sc.ID = so.ID ORDER BY sc.COLID FOR XML PATH('')) AS Body FROM SYSOBJECTS AS so WHERE so.TYPE IN ('C', 'D', 'FN', 'IF', 'P', 'R', 'RF', 'TF', 'TR', 'V', 'X') ) AS p WHERE p.Body LIKE '%YourKeyWordHere%'
E 12°55'05.25"N 56°04'39.16"