
/*------ ATD 230757 ------*/
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'CarVoluPedido' AND COLUMN_NAME = 'idClienteCentroCusto') 
alter TABLE dbo.CarVoluPedido add idClienteCentroCusto INT NULL
go

IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'CarVoluPedido' AND COLUMN_NAME = 'idClienteCentroCusto')
update CarVoluPedido set idClienteCentroCusto = 0 where idClienteCentroCusto is null
go

IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'CarVoluPedido' AND COLUMN_NAME = 'idClienteCentroCusto')
alter table CarVoluPedido alter column idClienteCentroCusto int not null 
go

IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'CarVoluPedido' AND COLUMN_NAME = 'idClienteCentroCusto')
exec sp_bindefault 'UW_ZeroDefault','CarVoluPedido.idClienteCentroCusto'
GO