IF  not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RC_CRED_DEB_RC_CRED]') AND type in (N'U'))
begin
	/****** Object:  Table [dbo].[RC_CRED_DEB_RC_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_DEB_RC_CRED](
		[CD_EMP]	[int] NOT NULL CONSTRAINT [DF_RC_CRED_DEB_RC_CRED_CD_EMP]		DEFAULT ((0)),
		[CD_FILIAL] [int] NOT NULL CONSTRAINT [DF_RC_CRED_DEB_RC_CRED_CD_FILIAL]	DEFAULT ((0)),
		[CD_RC_DEB] [int] NOT NULL CONSTRAINT [DF_RC_CRED_DEB_RC_CRED_CD_RC_DEB]	DEFAULT ((0)),
		[CD_DP_LANC]	[int] NOT NULL CONSTRAINT [DF_RC_CRED_DEB_RC_CRED_CD_DP_LANC]		DEFAULT ((0)),
	 
		[CD_FILIAL_CRED_DEB] [int] NOT NULL CONSTRAINT [DF_RC_CRED_DEB_RC_CRED_CD_FILIAL_CRED_DEB]	DEFAULT ((0)),
		[CD_RC_DEB_CRED_DEB] [int] NOT NULL CONSTRAINT [DF_RC_CRED_DEB_RC_CD_RC_DEB_CRED_DEB]	DEFAULT ((0)),
		[CD_CRED_CRED_DEB]	[int] NOT NULL CONSTRAINT [DF_RC_CRED_DEB_RC_CD_CRED_CRED_DEB]		DEFAULT ((0)),
		[CD_DEB_CRED_DEB]	[int] NOT NULL CONSTRAINT [DF_RC_CRED_DEB_RC_CD_DEB_CRED_DEB]		DEFAULT ((0)),  

	 CONSTRAINT [PK_RC_CRED_DEB_RC_CRED] PRIMARY KEY CLUSTERED 
	(
		[CD_DP_LANC],
		[CD_RC_DEB] ,
		[CD_FILIAL],
		[CD_EMP]
	 
	)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_DEB_RC_CRED]  WITH NOCHECK ADD  CONSTRAINT [FK_RC_CRED_DEB_RC_CRED_RC_CRED_DEB] 
		FOREIGN KEY(CD_DEB_CRED_DEB, CD_CRED_CRED_DEB, CD_RC_DEB_CRED_DEB, CD_FILIAL_CRED_DEB, CD_EMP)
	REFERENCES [dbo].[RC_CRED_DEB] (CD_DEB, CD_CRED, CD_RC_DEB, CD_FILIAL, CD_EMP)
	ON UPDATE CASCADE 
		ALTER TABLE [dbo].[RC_CRED_DEB_RC_CRED] CHECK CONSTRAINT [FK_RC_CRED_DEB_RC_CRED_RC_CRED_DEB] 

	ALTER TABLE [dbo].[RC_CRED_DEB_RC_CRED]  WITH NOCHECK ADD  CONSTRAINT [FK_RC_CRED_DEB_RC_CRED_RC_CRED] 
		FOREIGN KEY(CD_EMP ,CD_FILIAL, CD_RC_DEB,CD_DP_LANC)
	REFERENCES [dbo].[RC_CRED] (CD_EMP ,CD_FILIAL, CD_RC_DEB,CD_DP_LANC) 
		ALTER TABLE [dbo].[RC_CRED_DEB_RC_CRED] CHECK CONSTRAINT [FK_RC_CRED_DEB_RC_CRED_RC_CRED]  

END
 