/*============*/
/* PARAMETROS */
/*============*/
-- FN = SQL_SCALAR_FUNCTION
-- P = SQL_STORED_PROCEDURE
-- V = VIEW
DECLARE @TIPO VARCHAR(2)
DECLARE @CONTEUDO VARCHAR(MAX)
SET @TIPO = 'P'
SET @CONTEUDO = 'texto'
SELECT
A.TYPE AS TIPO,
A.NAME AS NOME,
A.CREATE_DATE AS DATA_CRIACAO,
A.MODIFY_DATE AS ULTIMA_MODIFICACAO,
B.DEFINITION AS CONTEUDO,
CASE WHEN B.DEFINITION IS NULL THEN 1 ELSE 0 END AS ESTA_CRIPTOGRAFADA
FROM SYS.ALL_OBJECTS A WITH(NOLOCK)
JOIN SYS.SQL_MODULES B WITH(NOLOCK)
ON B.OBJECT_ID = A.OBJECT_ID
WHERE (A.TYPE = @TIPO OR @TIPO IS NULL)
AND (B.DEFINITION LIKE '%' + @CONTEUDO + '%' OR @CONTEUDO IS NULL)
AND A.IS_MS_SHIPPED = 0
SQL