
IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='EST_COMPRAS_AGENDA_LIBERACAO') 
BEGIN
CREATE TABLE [dbo].[EST_COMPRAS_AGENDA_LIBERACAO](
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[CD_AGENDA] [int] NOT NULL,
	[CD_CTR_AGENDA] [int] NOT NULL,
	[CD_PED] [int] NOT NULL,
	[DT_CAD] [datetime] NOT NULL,
	[DT_LIB] [datetime] NULL,
	[PARAM_ESTOQUE] [int] NOT NULL,
	[CURVA_A] [int] NOT NULL,
	[CURVA_B] [int] NOT NULL,
	[CURVA_C] [int] NOT NULL,
	[CURVA_D] [int] NOT NULL,
	[CURVA_AA] [int] NOT NULL,
	[CD_COMPRADOR] [int] NOT NULL,
	[STS_LIB] [int] NOT NULL,
	[CD_USU_LIB] [int] NOT NULL,
 CONSTRAINT [PK_EST_COMPRAS_AGENDA_LIBERACAO] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_FILIAL] ASC,
	[CD_AGENDA] ASC,
	[CD_CTR_AGENDA] ASC,
	[CD_PED] 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_COMPRAS_AGENDA_LIBERACAO] ADD  CONSTRAINT [DF_EST_COMPRAS_AGENDA_LIBERACAO_STS_LIB]  DEFAULT ((0)) FOR [STS_LIB];

ALTER TABLE [dbo].[EST_COMPRAS_AGENDA_LIBERACAO] ADD  CONSTRAINT [DF_EST_COMPRAS_AGENDA_LIBERACAO_CD_USU_LIB]  DEFAULT ((0)) FOR [CD_USU_LIB];

END
