
/*------ ATD 344006 ------*/
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'OBSERVACAOFISCALNOTA' AND COLUMN_NAME = 'TIPO') 
alter TABLE dbo.OBSERVACAOFISCALNOTA add TIPO CHAR (1)
go
Update ObservacaoFiscalNota set tipo = 'E' where tipo is null and numord in (select numord from nfentracad) 
Update ObservacaoFiscalNota set tipo = 'S' where tipo is null and numord in (select numord from nfsaidacad) 
go

IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'AJUSTEFISCALITEM' AND COLUMN_NAME = 'TIPO') 
alter TABLE dbo.AJUSTEFISCALITEM add TIPO CHAR (1)
go
Update AjusteFiscalItem set tipo = 'E' where tipo is null and numord in (select numord from nfentracad) 
Update AjusteFiscalItem set tipo = 'S' where tipo is null and numord in (select numord from nfsaidacad) 
go