
/*------ ATD 408927 ------*/
IF NOT EXISTS (SELECT 1 FROM SYSCOLUMNS WHERE name = 'FLAGDESPINCLUSANAOTRIBUTADA' and syscolumns.id IN (SELECT ID FROM SYSOBJECTS WHERE xtype='U' AND name='COMPLEMENTONFSAIDA')) 
ALTER TABLE COMPLEMENTONFSAIDA ADD FLAGDESPINCLUSANAOTRIBUTADA NUMERIC(1,0) 
go
/*------ ATD 414045 ------*/
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'PLATAFORMA_ECOMMERCE' and column_name = 'REGRAFILIALRETIRADA')
begin
	ALTER TABLE PLATAFORMA_ECOMMERCE ADD REGRAFILIALRETIRADA NUMERIC(1) NOT NULL DEFAULT 0

	-- Configurar automaticamente os clientes que usavam o recurso
	EXEC('UPDATE PLATAFORMA_ECOMMERCE SET REGRAFILIALRETIRADA = 2 
	WHERE REGRAFILIALRETIRADA = 0 AND EXISTS(SELECT 1 FROM FILIAL_RETIRADA_ECOMMERCE F WHERE RPLATAFORMA = PLATAFORMA_ECOMMERCE.OID)')
end
go