IF EXISTS
(
    SELECT *
    FROM sys.views
    WHERE object_id = OBJECT_ID(N'[dbo].V_EST_PROD_NCM_CADASTRO_IBPT_CARGA_TENTACLE')
)
    DROP VIEW [dbo].[V_EST_PROD_NCM_CADASTRO_IBPT_CARGA_TENTACLE];
GO
CREATE VIEW [dbo].[V_EST_PROD_NCM_CADASTRO_IBPT_CARGA_TENTACLE]
AS
	SELECT 
		F.CD_EMP
		,F.CD_FILIAL
		,I.NR_NCM
		,I.UF
		,I.PERC_ALIQ_FEDERAL_NACIONAL
		,I.PERC_ALIQ_FEDERAL_IMPORTADOR
		,I.PERC_ALIQ_ESTADUAL
		,I.PERC_ALIQ_MUNICIPAL

	FROM PRC_FILIAL F
		INNER JOIN GLB_CID C ON F.CD_CID = C.CD_CID
		INNER JOIN EST_PROD_NCM_CADASTRO_IBPT I ON C.UF = I.UF COLLATE SQL_Latin1_General_CP1_CI_AS
	WHERE F.CD_EMP = 1

GO
