IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'dbo.CFUJ_Contrato_Cli_Hab') 
                   and type = 'FN')
BEGIN
    DROP FUNCTION dbo.CFUJ_Contrato_Cli_Hab
END
GO

CREATE FUNCTION [dbo].[CFUJ_Contrato_Cli_Hab](@pJson VARCHAR(8000))
RETURNS VARCHAR(8000)
AS
BEGIN

/*Variables recibidas por parametro a traves del JSON*/
DECLARE @pId_Cliente		INT
DECLARE @pId_Familia		INT
DECLARE @pId_Producto		VARCHAR(14)

SET @pId_Cliente			= ISNULL(CONVERT(INT, dbo.CF_JSON_VALUE(@pJson,'Id_Cliente')), 0)
SET @pId_Familia			= ISNULL(CONVERT(INT, dbo.CF_JSON_VALUE(@pJson,'Id_Familia')), 0)
SET @pId_Producto			= ISNULL(CONVERT(VARCHAR(14), dbo.CF_JSON_VALUE(@pJson,'Id_Producto')), '')
/*FIN Variables recibidas por parametro a traves del JSON*/

/*Variables Locales*/
DECLARE @Respuesta			VARCHAR(8000)
/*FIN Variables Locales*/


--==========================================================================================
/*IMPLEMENTAR*/
--==========================================================================================


RETURN ISNULL(@Respuesta,'1')
END
