
IF EXISTS
(
    SELECT *
    FROM sys.views
    WHERE object_id = OBJECT_ID(N'[dbo].V_RC_CLI_CONV_RC_CLI_TENTACLE')
)
    DROP VIEW [dbo].[V_RC_CLI_CONV_RC_CLI_TENTACLE];
GO
CREATE VIEW [DBO].[V_RC_CLI_CONV_RC_CLI_TENTACLE]
AS
     SELECT CC.CD_EMP, 
            CC.CD_CONV, 
            CC.CD_CLI, 
            CC.VLR_DEB, 
            CC.VLR_CRED, 
            CC.FLAG_N_EXP_VD_LAY, 
            ISNULL(CC.PERC_REC_MIN_CONV, 0) AS PERC_REC_MIN_CONV, 
            ISNULL(CC.PERC_REC_MAX_CONV, 0) AS PERC_REC_MAX_CONV, 
            CC.STS_CRED, 
            CC.STS_ATIVO, 
            CC.MATRICULA, 
            GETDATE() DT_HR_CARGA, 
            CC.VLR_DEB_FUTURO,
			CC.CD_PLANO_VENDA
     FROM RC_CLI_CONV_RC_CLI AS CC
          INNER JOIN DBO.RC_CLI ON CC.CD_EMP = DBO.RC_CLI.CD_EMP
                                   AND CC.CD_CLI = DBO.RC_CLI.CD_CLI
     WHERE CC.CD_EMP = 1;
GO