update Versao
set PatchVersao = 4
where versao = 3
  and subversao = 3
GO

Alter table Empresas disable  trigger all
GO

if not exists (Select * from dbo.SysColumns Where id = object_id(N'[dbo].[Empresas]') and 
                                                 Name Like 'TipoContribuinteIPI' And
                                                 OBJECTPROPERTY(id, N'IsUserTable') = 1 )
begin
  alter table Empresas  add TipoContribuinteIPI Smallint
end
go

sp_bindefault 'dbo.Numero', 'Empresas.TipoContribuinteIPI' 
go
   
update Empresas set
TipoContribuinteIPI = 0
where
TipoContribuinteIPI is null
go


alter table Empresas  alter column TipoContribuinteIPI Smallint   not null
go

Alter table Empresas enable  trigger all
go