IF  not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RC_CRED_CRED]') AND type in (N'U'))
begin

	/****** Object:  Table [dbo].[RC_CRED_CRED]    Script Date: 08/10/2015 10:54:26 ******/
	SET ANSI_NULLS ON 
	SET QUOTED_IDENTIFIER ON 
	SET ANSI_PADDING ON 

	CREATE TABLE [dbo].[RC_CRED_CRED](
		[CD_EMP]	[int] NOT NULL CONSTRAINT [DF_RC_CRED_CRED_CD_EMP]		DEFAULT ((0)),
		[CD_FILIAL] [int] NOT NULL CONSTRAINT [DF_RC_CRED_CRED_CD_FILIAL]	DEFAULT ((0)),
		[CD_RC_DEB] [int] NOT NULL CONSTRAINT [DF_RC_CRED_CRED_CD_RC_DEB]	DEFAULT ((0)),
		[CD_CRED]	[int] NOT NULL CONSTRAINT [DF_RC_CRED_CRED_CD_CRED]		DEFAULT ((0)),
		[DT_CRED]	[datetime] NOT NULL,
		[VL_CRED]	[money] NOT NULL CONSTRAINT [DF_DF_RC_CRED_CRED_VL_CRED]	DEFAULT ((0)),
		[VL_SLD]	[money] NOT NULL CONSTRAINT [DF_DF_RC_CRED_CRED_VL_SLD]		DEFAULT ((0)),
		[HIST]		[varchar](150) NOT NULL CONSTRAINT [DF_RC_CRED_CRED_HIST]	DEFAULT (''),
		[CD_USU]	[int] NOT NULL CONSTRAINT [DF_RC_CRED_CRED_CD_USU]  DEFAULT ((0)),
		[DT_CAD]	[datetime] NOT NULL,
	
	 CONSTRAINT [PK_RC_CRED_CRED] PRIMARY KEY CLUSTERED 
	(
		[CD_CRED] ASC,
		[CD_RC_DEB] ASC,
		[CD_FILIAL] ASC,
		[CD_EMP] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
	) ON [PRIMARY]
 
	SET ANSI_PADDING OFF 
	ALTER TABLE [dbo].[RC_CRED_CRED]  WITH NOCHECK ADD  CONSTRAINT [FK_RC_CRED_CRED_RC_DEB] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_RC_DEB])
	REFERENCES [dbo].[RC_DEB] ([CD_EMP], [CD_FILIAL], [CD_RC_DEB])
	ON UPDATE CASCADE 
	ALTER TABLE [dbo].[RC_CRED_CRED] CHECK CONSTRAINT [FK_RC_CRED_CRED_RC_DEB] 
END