/****** Object:  Table [dbo].[RC_DEB_HISTORICO_CPL]    Script Date: 11/07/2012 19:57:51 ******/
IF  NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RC_DEB_HISTORICO_CPL]') AND type in (N'U'))
begin
	CREATE TABLE [dbo].[RC_DEB_HISTORICO_CPL](
		[CD_CTR] [int] NOT NULL,
		[CD_EMP] [int] NOT NULL,
		[CD_FILIAL] [int] NOT NULL,
		[CD_RC_DEB] [int] NOT NULL,
		[VLR_DP] [money] NOT NULL,
		[DT_VENCTO] [datetime] NOT NULL,
		[SLD_DP] [money] NOT NULL,
		[STS_DP] [int] NOT NULL,
		[COB] [int] NOT NULL,
		[NR_BOLETA] [varchar](50) NOT NULL,
		[CD_HIST] [int] NOT NULL,
		[VLR_COMIS_CARTAO] [money] NOT NULL,
		[VLR_DESC] [money] NOT NULL,
		[DT_PRORROG] [datetime] NULL,
		[PERC_JUROS] [money] NOT NULL,
		[VLR_IMP] [money] NOT NULL,
		[VLR_GLOSA] [money] NOT NULL,
		[CD_CLI] [int] NOT NULL,
	 CONSTRAINT [PK_RC_DEB_HISTORICO_CPL] PRIMARY KEY CLUSTERED 
	(
		[CD_CTR] ASC,
		[CD_EMP] ASC,
		[CD_FILIAL] ASC,
		[CD_RC_DEB] 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].[RC_DEB_HISTORICO_CPL]  WITH CHECK ADD  CONSTRAINT [FK_RC_DEB_HISTORICO_CPL_RC_DEB_HISTORICO] FOREIGN KEY([CD_CTR])
	REFERENCES [dbo].[RC_DEB_HISTORICO] ([CD_CTR])
	ON DELETE CASCADE

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] CHECK CONSTRAINT [FK_RC_DEB_HISTORICO_CPL_RC_DEB_HISTORICO]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_CD_CTR]  DEFAULT ((0)) FOR [CD_CTR]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_CD_FILIAL]  DEFAULT ((0)) FOR [CD_FILIAL]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_CD_RC_DEB]  DEFAULT ((0)) FOR [CD_RC_DEB]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_VLR_DP]  DEFAULT ((0)) FOR [VLR_DP]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_SLD_DP]  DEFAULT ((0)) FOR [SLD_DP]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_STS_DP]  DEFAULT ((0)) FOR [STS_DP]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_COB]  DEFAULT ((0)) FOR [COB]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_NR_BOLETA]  DEFAULT ('') FOR [NR_BOLETA]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_CD_HIST]  DEFAULT ((0)) FOR [CD_HIST]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_VLR_COMIS_CARTAO]  DEFAULT ((0)) FOR [VLR_COMIS_CARTAO]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_VLR_DESC]  DEFAULT ((0)) FOR [VLR_DESC]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_DT_PRORROG]  DEFAULT ((0)) FOR [DT_PRORROG]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_PERC_JUROS]  DEFAULT ((0)) FOR [PERC_JUROS]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_VLR_IMP]  DEFAULT ((0)) FOR [VLR_IMP]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_VLR_GLOSA]  DEFAULT ((0)) FOR [VLR_GLOSA]

	ALTER TABLE [dbo].[RC_DEB_HISTORICO_CPL] ADD  CONSTRAINT [DF_RC_DEB_HISTORICO_CPL_CD_CLI]  DEFAULT ((0)) FOR [CD_CLI]
end

