IF EXISTS
(
    SELECT *
    FROM sys.views
    WHERE object_id = OBJECT_ID(N'[dbo].V_GLB_COND_PGTO_CPL_TENTACLE')
)
    DROP VIEW [dbo].[V_GLB_COND_PGTO_CPL_TENTACLE];
GO

CREATE VIEW [dbo].[V_GLB_COND_PGTO_CPL_TENTACLE] AS 
SELECT
	GLB_COND_PGTO.CD_EMP,
	GLB_COND_PGTO.CD_COND_PGTO,
	ISNULL(GLB_COND_PGTO_CPL.NR_VENCTO,0) AS NR_VENCTO,
	ISNULL(GLB_COND_PGTO_CPL.DIAS_VENCTO,1) AS DIAS_VENCTO
FROM
	GLB_COND_PGTO LEFT OUTER JOIN GLB_COND_PGTO_CPL ON
	GLB_COND_PGTO.CD_EMP = GLB_COND_PGTO_CPL.CD_EMP AND
	GLB_COND_PGTO.CD_COND_PGTO = GLB_COND_PGTO_CPL.CD_COND_PGTO 
WHERE GLB_COND_PGTO.CD_EMP = 1
GO
