
IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='EST_COMPRAS_AGENDA_LIBERACAO') 
BEGIN
	ALTER TABLE EST_COMPRAS_AGENDA_LIBERACAO
	DROP CONSTRAINT PK_EST_COMPRAS_AGENDA_LIBERACAO

	ALTER TABLE EST_COMPRAS_AGENDA_LIBERACAO
	ADD
	 CONSTRAINT [PK_EST_COMPRAS_AGENDA_LIBERACAO] PRIMARY KEY CLUSTERED 
	(
		[CD_EMP] ASC,
		[CD_FILIAL] ASC,
		[CD_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]
	 
	ALTER TABLE EST_COMPRAS_AGENDA_LIBERACAO ALTER COLUMN CD_CTR_AGENDA INT NULL

	ALTER TABLE [dbo].[EST_COMPRAS_AGENDA_LIBERACAO] 
	ADD  CONSTRAINT [DF_EST_COMPRAS_AGENDA_LIBERACAO_CD_CTR_AGENDA]  DEFAULT ((0)) FOR [CD_CTR_AGENDA]

END