/****** Object:  Table [dbo].[CTB_APURA_ICMS_DIFAL]    Script Date: 08/15/2013 15:08:20 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * 
                 FROM INFORMATION_SCHEMA.TABLES 
                 WHERE TABLE_SCHEMA = 'dbo' 
                 AND  TABLE_NAME = 'CTB_APURA_ICMS_DIFAL')
BEGIN
	CREATE TABLE [dbo].[CTB_APURA_ICMS_DIFAL](
		[CD_EMP] [int] NOT NULL,
		[CD_FILIAL] [int] NOT NULL,
		[UF] [VARCHAR](2) NOT NULL,
		[MES_APURAC] [int] NOT NULL,
		[ANO_APURAC] [int] NOT NULL,
		[TIPO] [int] NOT NULL,
		[VLR_TOT_CREDITO] [money] NULL,
		[VLR_TOT_DEBITO] [money] NULL,
		[VLR_SLD_CREDOR_ANT] [money] NULL,
		[VLR_SLD_APURADO] [money] NULL,
		[VLR_ICMS_RECOLHER] [money] NULL,
		[VLR_SLD_CREDOR_TRANSPORTAR] [money] NULL,
		[VLR_TOT_DED] [money] NULL,
		[VLR_AJ_CREDITO] [money] NULL,
		[VLR_AJ_DEBITO] [money] NULL,
		[VLR_TOT_AJ_CREDITO] [money] NULL,
		[VLR_TOT_AJ_DEBITO] [money] NULL,
		[VLR_ESTORNO_CRED] [money] NULL,
		[VLR_ESTORNO_DEB] [money] NULL,
		[DT_CAD] [datetime] NULL,
		[CD_USU] [int] NULL,
		[DT_ULT_ALT] [datetime] NULL,
		[CD_USU_ALT] [int] NULL,
		[VLR_OUT_DEB] [money] NULL,
		[VLR_OUT_CRED] [money] NULL,
		[VLR_ICMS_SUBS_ENT] [money] NULL,
		[VLR_ICMS_SUBS_SAI_UF] [money] NULL,
		[VLR_TOT_DIF_ALIQ_ICMS] [money] NULL,
		[VLR_TOT_OUT_OBRIG_ICMS] [money] NULL,
		[VLR_TOT_OUT_OBRIG_RECOLHER] [money] NULL,
		[VLR_TOT_ICMS_SUBS_SAI_OUT_UF] [money] NULL,
		[VLR_TOT_ICMS_IMPORTACAO] [money] NULL,
	 CONSTRAINT [PK_CTB_APURA_ICMS_DIFAL] PRIMARY KEY CLUSTERED 
	(
		[CD_EMP] ASC,
		[CD_FILIAL] ASC,
		[UF] ASC,
		[MES_APURAC] ASC,
		[ANO_APURAC] ASC,
		[TIPO] 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].[CTB_APURA_ICMS_DIFAL] ADD  CONSTRAINT [DF_CTB_APURA_ICMS_DIFAL_VLR_OUT_DEB]  DEFAULT ((0)) FOR [VLR_OUT_DEB]

ALTER TABLE [dbo].[CTB_APURA_ICMS_DIFAL] ADD  CONSTRAINT [DF_CTB_APURA_ICMS_DIFAL_VLR_OUT_CRED]  DEFAULT ((0)) FOR [VLR_OUT_CRED]

ALTER TABLE [dbo].[CTB_APURA_ICMS_DIFAL] ADD  CONSTRAINT [DF_CTB_APURA_ICMS_DIFAL_VLR_ICMS_SUBS_ENT]  DEFAULT ((0)) FOR [VLR_ICMS_SUBS_ENT]

ALTER TABLE [dbo].[CTB_APURA_ICMS_DIFAL] ADD  CONSTRAINT [DF_CTB_APURA_ICMS_DIFAL_VLR_ICMS_SUBS_SAI_UF]  DEFAULT ((0)) FOR [VLR_ICMS_SUBS_SAI_UF]

ALTER TABLE [dbo].[CTB_APURA_ICMS_DIFAL] ADD  CONSTRAINT [DF_CTB_APURA_ICMS_DIFAL_VLR_TOT_DIF_ALIQ_ICMS]  DEFAULT ((0)) FOR [VLR_TOT_DIF_ALIQ_ICMS]

ALTER TABLE [dbo].[CTB_APURA_ICMS_DIFAL] ADD  CONSTRAINT [DF_CTB_APURA_ICMS_DIFAL_VLR_TOT_OUT_OBRIG_ICMS]  DEFAULT ((0)) FOR [VLR_TOT_OUT_OBRIG_ICMS]

ALTER TABLE [dbo].[CTB_APURA_ICMS_DIFAL] ADD  CONSTRAINT [DF_CTB_APURA_ICMS_DIFAL_VLR_TOT_OUT_OBRIG_RECOLHER]  DEFAULT ((0)) FOR [VLR_TOT_OUT_OBRIG_RECOLHER]

ALTER TABLE [dbo].[CTB_APURA_ICMS_DIFAL] ADD  CONSTRAINT [DF_CTB_APURA_ICMS_DIFAL_VLR_TOT_ICMS_SUBS_SAI_OUT_UF]  DEFAULT ((0)) FOR [VLR_TOT_ICMS_SUBS_SAI_OUT_UF]

ALTER TABLE [dbo].[CTB_APURA_ICMS_DIFAL] ADD  CONSTRAINT [DF_CTB_APURA_ICMS_DIFAL_VLR_TOT_ICMS_IMPORTACAO]  DEFAULT ((0)) FOR [VLR_TOT_ICMS_IMPORTACAO]

END
