IF EXISTS (SELECT 1 FROM SYS.VIEWS WHERE OBJECT_NAME(OBJECT_ID) =    'V_CHQ_DEPOS_CHQ_REDEPOS') 
	DROP VIEW V_CHQ_DEPOS_CHQ_REDEPOS
GO   
CREATE VIEW [DBO].[V_CHQ_DEPOS_CHQ_REDEPOS]      
AS      
SELECT        
  DBO.CHQ_DEVO.CD_EMP,      
  DBO.CHQ_DEVO.CD_DEVO,       
  DBO.CHQ_DEVO.CD_CHQ,       
  DBO.CHQ_DEVO.DT_DEVO,       
  DBO.CHQ_REDEPOS.DT_REDEPOS,       
  ISNULL(DBO.CHQ_DEVO_HIST.DS_HIST,'') AS DS_HIST,       
  CHQ_DEVO.OBS_CHQ,      
  V_CHQ_DEPOS_CHQ_DEPOS_CPL.DT_DEPOS,      
  DBO.CHQ_DEVO_HIST.TP_HIST,      
  ISNULL(CHQ_DEVO_HIST.CD_HIST,0) AS CD_HIST,    
  CHQ_REDEPOS.DT_CAD    
FROM          
  DBO.CHQ_DEVO LEFT OUTER JOIN DBO.CHQ_DEVO_HIST  ON       
  DBO.CHQ_DEVO_HIST.CD_HIST = DBO.CHQ_DEVO.CD_HIST       
  LEFT OUTER JOIN DBO.CHQ_REDEPOS       
  INNER JOIN DBO.CHQ_DEVO_CHQ_REDEPOS ON       
  DBO.CHQ_REDEPOS.CD_EMP = DBO.CHQ_DEVO_CHQ_REDEPOS.CD_EMP AND       
        DBO.CHQ_REDEPOS.CD_REDEPOS = DBO.CHQ_DEVO_CHQ_REDEPOS.CD_REDEPOS ON       
        DBO.CHQ_DEVO.CD_DEVO = DBO.CHQ_DEVO_CHQ_REDEPOS.CD_DEVO AND       
  DBO.CHQ_DEVO.CD_EMP = DBO.CHQ_DEVO_CHQ_REDEPOS.CD_EMP      
  INNER JOIN  V_CHQ_DEPOS_CHQ_DEPOS_CPL ON      
  DBO.CHQ_DEVO.CD_CHQ = V_CHQ_DEPOS_CHQ_DEPOS_CPL.CD_CHQ AND       
  DBO.CHQ_DEVO.CD_EMP = V_CHQ_DEPOS_CHQ_DEPOS_CPL.CD_EMP