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

CREATE VIEW [dbo].[V_EST_PROD_PRECO_DESC_PRG_CPL_TENTACLE]
AS
     SELECT PRG_FIL.CD_EMP,
            PRG_FIL.CD_FILIAL,
            PRG_CPL.CD_PRECO_PRG,
            PRG_CPL.CD_PROD,
            PRG_CPL.PERC_DESC,
    GETDATE() as DT_HR_CARGA
     FROM EST_PROD_PRECO_DESC_PRG PRG
          INNER JOIN EST_PROD_PRECO_DESC_PRG_CPL PRG_CPL ON PRG.CD_PRECO_PRG = PRG_CPL.CD_PRECO_PRG
          INNER JOIN EST_PROD_PRECO_DESC_PRG_PRC_FILIAL PRG_FIL ON PRG.CD_PRECO_PRG = PRG_FIL.CD_PRECO_PRG
     WHERE PRG.DT_VENCTO >= GETDATE();
GO
