IF  NOT EXISTS (SELECT * FROM sys.objects 
					WHERE object_id = OBJECT_ID(N'[dbo].[EST_PROD_NCM_CADASTRO_IBPT]') 
					AND type in (N'U')) 
BEGIN
CREATE TABLE [dbo].[EST_PROD_NCM_CADASTRO_IBPT](
	[NR_NCM] [varchar](50)  COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[UF] [varchar](10) NOT NULL,
	[PERC_ALIQ_FEDERAL_NACIONAL] [money] NOT NULL,
	[PERC_ALIQ_FEDERAL_IMPORTADOR] [money] NOT NULL,
	[PERC_ALIQ_ESTADUAL] [money] NOT NULL,
	[PERC_ALIQ_MUNICIPAL] [money] NOT NULL,
 CONSTRAINT [PK_EST_PROD_NCM_CADASTRO_IBPT] PRIMARY KEY CLUSTERED 
(
	[NR_NCM] ASC,
	[UF] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]


ALTER TABLE [dbo].[EST_PROD_NCM_CADASTRO_IBPT] ADD  CONSTRAINT [DF_EST_PROD_NCM_CADASTRO_IBPT_PERC_ALIQ_FEDERAL_NACIONAL]  DEFAULT ((0)) FOR [PERC_ALIQ_FEDERAL_NACIONAL]

ALTER TABLE [dbo].[EST_PROD_NCM_CADASTRO_IBPT] ADD  CONSTRAINT [DF_EST_PROD_NCM_CADASTRO_IBPT_PERC_ALIQ_FEDERAL_IMPORTADOR]  DEFAULT ((0)) FOR [PERC_ALIQ_FEDERAL_IMPORTADOR]

ALTER TABLE [dbo].[EST_PROD_NCM_CADASTRO_IBPT] ADD  CONSTRAINT [DF_EST_PROD_NCM_CADASTRO_IBPT_PERC_ALIQ_ESTADUAL]  DEFAULT ((0)) FOR [PERC_ALIQ_ESTADUAL]

ALTER TABLE [dbo].[EST_PROD_NCM_CADASTRO_IBPT] ADD  CONSTRAINT [DF_EST_PROD_NCM_CADASTRO_IBPT_PERC_ALIQ_MUNICIPAL]  DEFAULT ((0)) FOR [PERC_ALIQ_MUNICIPAL]

ALTER TABLE [dbo].[EST_PROD_NCM_CADASTRO_IBPT]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_NCM_CADASTRO_IBPT_EST_PROD_NCM_CADASTRO_IBPT] FOREIGN KEY([NR_NCM])
REFERENCES [dbo].[EST_PROD_NCM_CADASTRO] ([NR_NCM])

ALTER TABLE [dbo].[EST_PROD_NCM_CADASTRO_IBPT] CHECK CONSTRAINT [FK_EST_PROD_NCM_CADASTRO_IBPT_EST_PROD_NCM_CADASTRO_IBPT]
end