IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[V_RC_CLI]'))
begin
	DROP VIEW [dbo].[V_RC_CLI]
end

go
CREATE VIEW [dbo].[V_RC_CLI] AS  
SELECT dbo.RC_CLI.CD_EMP                                        ,  
       dbo.RC_CLI.CD_CLI                                        ,  
       dbo.RC_CLI.RZ_CLI                                        ,  
       dbo.RC_CLI.NM_FANT                                       ,  
       dbo.RC_CLI.CGC_CPF                                       ,  
       dbo.RC_CLI.DT_NASC                                       ,  
       dbo.RC_CLI_FIDELI_CARTAO.NR_CARTAO                       ,  
       dbo.RC_CLI.END_CLI                                       ,  
       dbo.RC_CLI.BAIRRO                                        ,  
       dbo.RC_CLI.TEL                                           ,  
       dbo.RC_CLI.TELEFONE1                                     ,  
       dbo.RC_CLI.TELEFONE2                                     ,  
       dbo.RC_CLI.TELEFONE3                                     ,  
       ISNULL(dbo.RC_CLI_CONV_RC_CLI.VLR_DEB, 0)    AS VLR_DEB  ,  
       ISNULL(dbo.RC_CLI_CONV_RC_CLI.VLR_CRED, 0)   AS VLR_CRED ,  
       ISNULL(dbo.RC_CLI_CONV_RC_CLI.MATRICULA, '') AS MATRICULA,  
       ISNULL(dbo.RC_CLI_CONV.CD_CONV, 0)           AS CD_CONV  ,  
       ISNULL(dbo.RC_CLI_CONV.DS_CONV, '')          AS DS_CONV  ,  
       dbo.RC_CLI.SENHA				, 
	   ISNULL(dbo.RC_CLI.COMPLEMENTO, '')          AS COMPLEMENTO      
FROM   dbo.RC_CLI  
       LEFT OUTER JOIN dbo.RC_CLI_FIDELI_CARTAO  
       ON     dbo.RC_CLI.CD_EMP = dbo.RC_CLI_FIDELI_CARTAO.CD_EMP  
       AND    dbo.RC_CLI.CD_CLI = dbo.RC_CLI_FIDELI_CARTAO.CD_CLI  
       LEFT OUTER JOIN dbo.RC_CLI_CONV_RC_CLI  
       ON     dbo.RC_CLI.CD_EMP = dbo.RC_CLI_CONV_RC_CLI.CD_EMP  
       AND    dbo.RC_CLI.CD_CLI = dbo.RC_CLI_CONV_RC_CLI.CD_CLI  
       LEFT OUTER JOIN dbo.RC_CLI_CONV  
       ON     dbo.RC_CLI_CONV_RC_CLI.CD_EMP  = dbo.RC_CLI_CONV.CD_EMP  
       AND    dbo.RC_CLI_CONV_RC_CLI.CD_CONV = dbo.RC_CLI_CONV.CD_CONV  
WHERE  ISNULL(CONV_HABILITADO,0)                   = 0
GO






