IF  not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RC_CREDIARIO_PARC_PDV_VD_DEV_NCC]') AND type in (N'U'))
begin
CREATE TABLE [dbo].[RC_CREDIARIO_PARC_PDV_VD_DEV_NCC](
	[CD_CTR] [int] NOT NULL,
	[CD_CTR_NCC] [int] NOT NULL,
	[CD_CTR_PGTO] [int] NULL,
 CONSTRAINT [PK_RC_CREDIARIO_PARC_PDV_VD_DEV_NCC] PRIMARY KEY CLUSTERED 
(
	[CD_CTR] ASC,
	[CD_CTR_NCC] 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_CREDIARIO_PARC_PDV_VD_DEV_NCC] ADD  CONSTRAINT [DF_RC_CREDIARIO_PARC_PDV_VD_DEV_NCC_CD_CTR]  DEFAULT ((0)) FOR [CD_CTR]


ALTER TABLE [dbo].[RC_CREDIARIO_PARC_PDV_VD_DEV_NCC] ADD  CONSTRAINT [DF_RC_CREDIARIO_PARC_PDV_VD_DEV_NCC_CD_CTR_NCC]  DEFAULT ((0)) FOR [CD_CTR_NCC]

ALTER TABLE [dbo].[RC_CREDIARIO_PARC_PDV_VD_DEV_NCC]  WITH CHECK ADD  CONSTRAINT [FK_RC_CREDIARIO_PARC_PDV_VD_DEV_NCC_PDV_VD_DEV_NCC] FOREIGN KEY([CD_CTR_NCC])
REFERENCES [dbo].[PDV_VD_DEV_NCC] ([CD_CTR_NCC])


ALTER TABLE [dbo].[RC_CREDIARIO_PARC_PDV_VD_DEV_NCC] CHECK CONSTRAINT [FK_RC_CREDIARIO_PARC_PDV_VD_DEV_NCC_PDV_VD_DEV_NCC]


ALTER TABLE [dbo].[RC_CREDIARIO_PARC_PDV_VD_DEV_NCC]  WITH CHECK ADD  CONSTRAINT [FK_RC_CREDIARIO_PARC_PDV_VD_DEV_NCC_RC_CREDIARIO_PARC] FOREIGN KEY([CD_CTR])
REFERENCES [dbo].[RC_CREDIARIO_PARC] ([CD_CTR])


ALTER TABLE [dbo].[RC_CREDIARIO_PARC_PDV_VD_DEV_NCC] CHECK CONSTRAINT [FK_RC_CREDIARIO_PARC_PDV_VD_DEV_NCC_RC_CREDIARIO_PARC]


ALTER TABLE [dbo].[RC_CREDIARIO_PARC_PDV_VD_DEV_NCC]  WITH CHECK ADD  CONSTRAINT [FK_RC_CREDIARIO_PARC_PDV_VD_DEV_NCC_RC_PGTO_PDV] FOREIGN KEY([CD_CTR_PGTO])
REFERENCES [dbo].[RC_PGTO_PDV] ([CD_CTR_PGTO])


ALTER TABLE [dbo].[RC_CREDIARIO_PARC_PDV_VD_DEV_NCC] CHECK CONSTRAINT [FK_RC_CREDIARIO_PARC_PDV_VD_DEV_NCC_RC_PGTO_PDV]


end
