--Variable que contentendrá el texto a buscar, nombre de una tabla, columna, etc...
DECLARE @SearchText AS VARCHAR(100)
SET @SearchText = 'texto a buscar'
--Consulta de los procedimeintos que contienen dicho texto
SELECT DISTINCT o.id AS 'ID Objeto', USER_NAME(o.uid) + '.' + OBJECT_NAME(c.id) AS 'Nombre Objeto',
CASE
WHEN OBJECTPROPERTY(c.id, 'IsReplProc') = 1
THEN 'Replication stored procedure'
WHEN OBJECTPROPERTY(c.id, 'IsExtendedProc') = 1
THEN 'Extended stored procedure'
WHEN OBJECTPROPERTY(c.id, 'IsProcedure') = 1
THEN 'Stored Procedure'
WHEN OBJECTPROPERTY(c.id, 'IsTrigger') = 1
THEN 'Trigger'
WHEN OBJECTPROPERTY(c.id, 'IsTableFunction') = 1
THEN 'Table-valued function'
WHEN OBJECTPROPERTY(c.id, 'IsScalarFunction') = 1
THEN 'Scalar-valued function'
WHEN OBJECTPROPERTY(c.id, 'IsInlineFunction') = 1
THEN 'Inline function'
WHEN OBJECTPROPERTY(c.id, 'IsView') = 1
THEN 'View'
END AS 'Tipo Objeto', m.definition AS 'SCRIPT'
FROM syscomments c
INNER JOIN
sysobjects o
ON c.id = o.id
INNER JOIN sys.sql_modules m
ON m.object_id = o.id
WHERE c.text LIKE '%'+@SearchText+'%' AND
encrypted = 0 AND
( OBJECTPROPERTY(c.id, 'IsReplProc') = 1 OR
OBJECTPROPERTY(c.id, 'IsExtendedProc') = 1 OR
OBJECTPROPERTY(c.id, 'IsProcedure') = 1 OR
OBJECTPROPERTY(c.id, 'IsTrigger') = 1 OR
OBJECTPROPERTY(c.id, 'IsTableFunction') = 1 OR
OBJECTPROPERTY(c.id, 'IsScalarFunction') = 1 OR
OBJECTPROPERTY(c.id, 'IsInlineFunction') = 1 OR
OBJECTPROPERTY(c.id, 'IsView') = 1 )
ORDER BY 'Tipo Objeto', 'Nombre Objeto