
/*------ ATD 386477 ------*/
-- SQLSERVER
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'ITNFSAICOMPLEMENTO' AND COLUMN_NAME = 'DESCONTOOFERTA') 
ALTER TABLE dbo.ITNFSAICOMPLEMENTO add DESCONTOOFERTA NUMERIC (15,2)
GO

IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'ITNFENTCOMPLEMENTO' AND COLUMN_NAME = 'DESCONTOOFERTA') 
ALTER TABLE dbo.ITNFENTCOMPLEMENTO add DESCONTOOFERTA NUMERIC (15,2)
GO

/*------ ATD 390161 ------*/
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'PRECOFUTURO' AND COLUMN_NAME = 'FILIAL') 
ALTER TABLE PRECOFUTURO add FILIAL CHAR (2) NOT NULL DEFAULT '' 
GO
UPDATE PrecoFuturo SET Filial = '' WHERE Filial IS NULL
GO
ALTER TABLE PrecoFuturo DROP PK_PRECOFUTURO
GO
ALTER TABLE PrecoFuturo ADD CONSTRAINT PK_PRECOFUTURO PRIMARY KEY (CodPro, DataPrevista, AreaVenda, Filial)
GO
