
/*------ ATD 456725 ------*/
IF NOT EXISTS (SELECT 1 FROM syscolumns WHERE name = 'FornecedorSimples' and syscolumns.id IN (SELECT id FROM sysobjects WHERE xtype = 'U' AND name = 'PediForCad'))
BEGIN
	ALTER TABLE PediForCad ADD FornecedorSimples TINYINT NULL
	EXEC('UPDATE PediForCad SET FornecedorSimples = 0 WHERE FornecedorSimples IS NULL')
	ALTER TABLE PediForCad ALTER COLUMN FornecedorSimples TINYINT NOT NULL
	EXEC sp_bindefault 'UW_ZeroDefault', 'PediForCad.FornecedorSimples'
END
GO

IF NOT EXISTS (SELECT 1 FROM syscolumns WHERE name = 'TransportadorSimples' and syscolumns.id IN (SELECT id FROM sysobjects WHERE xtype = 'U' AND name = 'PediForCad'))
BEGIN
	ALTER TABLE PediForCad ADD TransportadorSimples TINYINT NULL
	EXEC('UPDATE PediForCad SET TransportadorSimples = 0 WHERE TransportadorSimples IS NULL')
	ALTER TABLE PediForCad ALTER COLUMN TransportadorSimples TINYINT NOT NULL
	EXEC sp_bindefault 'UW_ZeroDefault', 'PediForCad.TransportadorSimples'
END
GO

IF NOT EXISTS (SELECT 1 FROM syscolumns WHERE name = 'FornecedorSimples' and syscolumns.id IN (SELECT id FROM sysobjects WHERE xtype = 'U' AND name = 'Previa'))
BEGIN
	ALTER TABLE Previa ADD FornecedorSimples TINYINT NULL
	EXEC('UPDATE Previa SET FornecedorSimples = 0 WHERE FornecedorSimples IS NULL')
	ALTER TABLE Previa ALTER COLUMN FornecedorSimples TINYINT NOT NULL
	EXEC sp_bindefault 'UW_ZeroDefault', 'Previa.FornecedorSimples'
END
GO

IF NOT EXISTS (SELECT 1 FROM syscolumns WHERE name = 'TransportadorSimples' and syscolumns.id IN (SELECT id FROM sysobjects WHERE xtype = 'U' AND name = 'Previa'))
BEGIN
	ALTER TABLE Previa ADD TransportadorSimples TINYINT NULL
	EXEC('UPDATE Previa SET TransportadorSimples = 0 WHERE TransportadorSimples IS NULL')
	ALTER TABLE Previa ALTER COLUMN TransportadorSimples TINYINT NOT NULL
	EXEC sp_bindefault 'UW_ZeroDefault', 'Previa.TransportadorSimples'
END
GO
