IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_PROD_CPL_DEMANDA_PROC_CPL_PENDENTE_APLICAR_MEDIAF]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[EST_PROD_CPL_DEMANDA_PROC_CPL_PENDENTE_APLICAR_MEDIAF](
	[CD_CTR_PROC_CPL] [int] NOT NULL,
	[DT_CAD] [datetime] NULL,
 CONSTRAINT [PK_EST_PROD_CPL_DEMANDA_PROC_CPL_PENDENTE_APLICAR_MEDIAF] PRIMARY KEY CLUSTERED 
(
	[CD_CTR_PROC_CPL] 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].[EST_PROD_CPL_DEMANDA_PROC_CPL_PENDENTE_APLICAR_MEDIAF]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_CPL_DEMANDA_PROC_CPL_PENDENTE_APLICAR_MEDIAF_EST_PROD_CPL_DEMANDA_PROC_CPL] FOREIGN KEY([CD_CTR_PROC_CPL])
REFERENCES [dbo].[EST_PROD_CPL_DEMANDA_PROC_CPL] ([CD_CTR])

ALTER TABLE [dbo].[EST_PROD_CPL_DEMANDA_PROC_CPL_PENDENTE_APLICAR_MEDIAF] CHECK CONSTRAINT [FK_EST_PROD_CPL_DEMANDA_PROC_CPL_PENDENTE_APLICAR_MEDIAF_EST_PROD_CPL_DEMANDA_PROC_CPL]
END

