IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES
			 WHERE TABLE_NAME='CTB_APURA_ICMS_AJUSTES_EST_NF_ENT_IT')
			 
BEGIN
	CREATE TABLE [dbo].[CTB_APURA_ICMS_AJUSTES_EST_NF_ENT_IT](
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[CD_CTR] [int] NOT NULL,
	[CD_NF] [int] NOT NULL,
	[CD_PROD] [int] NOT NULL,
	[CD_IT] [int] NOT NULL,
	[CD_NT_OP] [int] NOT NULL,
	[TP_AJUSTE_CFOP] [int] NOT NULL,
	[VLR_BASE_ICMS] [money] NULL,
	[ALIQ_ICMS] [money] NULL,
	[PERC_ALIQ_OUTORG] [money] NULL,
	[VLR_AJUSTE] [money] NULL,
	[DT_CAD] [datetime] NULL,
	[CD_USU] [int] NULL,
		 CONSTRAINT [PK_CTB_APURA_ICMS_AJUSTES_EST_NF_ENT_IT] PRIMARY KEY CLUSTERED 
		(
			[CD_EMP] ASC,
			[CD_FILIAL] ASC,
			[CD_CTR] ASC,
			[CD_NF] ASC,
			[CD_PROD] ASC
		)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = ON, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 97) ON [PRIMARY]
	) ON [PRIMARY]


	ALTER TABLE [dbo].[CTB_APURA_ICMS_AJUSTES_EST_NF_ENT_IT]  WITH CHECK ADD  CONSTRAINT [FK_CTB_APURA_ICMS_AJUSTES_EST_NF_ENT_IT_CTB_APURA_ICMS_AJUSTES] FOREIGN KEY([CD_CTR])
	REFERENCES [dbo].[CTB_APURA_ICMS_AJUSTES] ([CD_CTR])


	ALTER TABLE [dbo].[CTB_APURA_ICMS_AJUSTES_EST_NF_ENT_IT] CHECK CONSTRAINT [FK_CTB_APURA_ICMS_AJUSTES_EST_NF_ENT_IT_CTB_APURA_ICMS_AJUSTES]


END