IF OBJECT_ID('RC_CLI_CONV_PBM_CENTRALIZADO') IS NULL

BEGIN
CREATE TABLE [dbo].[RC_CLI_CONV_PBM_CENTRALIZADO](
	[CD_CTR] [int] IDENTITY(1,1) NOT NULL,
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[CD_NF] [int] NOT NULL,
	[DT_CAD] [datetime] NOT NULL,
 CONSTRAINT [PK_RC_CLI_CONV_PBM_CENTRALIZADO] PRIMARY KEY CLUSTERED 
(
	[CD_CTR] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [IX_RC_CLI_CONV_PBM_CENTRALIZADO] UNIQUE NONCLUSTERED 
(
	[CD_NF] 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) ON [PRIMARY]
) ON [PRIMARY]

ALTER TABLE [dbo].[RC_CLI_CONV_PBM_CENTRALIZADO]  WITH CHECK ADD  CONSTRAINT [FK_RC_CLI_CONV_PBM_CENTRALIZADO_EST_NF_ENT] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_NF])
REFERENCES [dbo].[EST_NF_ENT] ([CD_EMP], [CD_FILIAL], [CD_NF])

ALTER TABLE [dbo].[RC_CLI_CONV_PBM_CENTRALIZADO] CHECK CONSTRAINT [FK_RC_CLI_CONV_PBM_CENTRALIZADO_EST_NF_ENT]
END

