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

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

	CREATE TABLE [dbo].[RC_DEB_PDV_VD_DEV_NCC]
	(
			[CD_EMP]	[int] NOT NULL CONSTRAINT [DF_RC_DEB_PDV_VD_DEV_NCC_CD_EMP]		DEFAULT ((0)),
			[CD_FILIAL] [int] NOT NULL CONSTRAINT [DF_RC_DEB_PDV_VD_DEV_NCC_CD_FILIAL]	DEFAULT ((0)),
			[CD_RC_DEB] [int] NOT NULL CONSTRAINT [DF_RC_DEB_PDV_VD_DEV_NCC_CD_RC_DEB]	DEFAULT ((0)),
			[CD_CTR_NCC] [int] NOT NULL CONSTRAINT [DF_RC_DEB_PDV_VD_DEV_NCC_CD_CTR_NCC]	DEFAULT ((0)),
		CONSTRAINT [PK_RC_DEB_PDV_VD_DEV_NCC] PRIMARY KEY CLUSTERED 
		(
			[CD_CTR_NCC] 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_DEB_PDV_VD_DEV_NCC]  
		WITH NOCHECK ADD  CONSTRAINT [FK_RC_DEB_PDV_VD_DEV_NCC_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_DEB_PDV_VD_DEV_NCC] CHECK CONSTRAINT [FK_RC_DEB_PDV_VD_DEV_NCC_RC_DEB] 

	ALTER TABLE [dbo].[RC_DEB_PDV_VD_DEV_NCC]  
		WITH NOCHECK ADD  CONSTRAINT [FK_RC_DEB_PDV_VD_DEV_NCC_PDV_VD_DEV_NCC] FOREIGN KEY([CD_CTR_NCC])
		REFERENCES [dbo].[PDV_VD_DEV_NCC] ([CD_CTR_NCC])
	ON UPDATE CASCADE 
	ALTER TABLE [dbo].[RC_DEB_PDV_VD_DEV_NCC] CHECK CONSTRAINT [FK_RC_DEB_PDV_VD_DEV_NCC_PDV_VD_DEV_NCC] 

END