IF NOT EXISTS(SELECT 1 
          FROM INFORMATION_SCHEMA.COLUMNS 
          WHERE 
            TABLE_NAME = 'Customer' AND 
            COLUMN_NAME = 'DebtorAccount')
BEGIN           
  ALTER TABLE Customer ADD DebtorAccount VARCHAR(20)
END
GO

IF EXISTS(SELECT 1 
          FROM INFORMATION_SCHEMA.COLUMNS 
          WHERE 
            TABLE_NAME = 'Customer' AND 
            COLUMN_NAME = 'DebitorAccountNumber') AND
   EXISTS(SELECT 1 
          FROM INFORMATION_SCHEMA.COLUMNS 
          WHERE 
            TABLE_NAME = 'Customer' AND 
            COLUMN_NAME = 'DebtorAccount')              
BEGIN      
  UPDATE Customer
  SET Customer.DebtorAccount = Customer.DebitorAccountNumber
  WHERE Customer.DebitorAccountNumber <> 0   
END
GO

IF EXISTS(SELECT 1 
          FROM INFORMATION_SCHEMA.COLUMNS 
          WHERE 
            TABLE_NAME = 'Customer' AND 
            COLUMN_NAME = 'DebitorAccountNumber')
BEGIN           
  ALTER TABLE Customer DROP COLUMN DebitorAccountNumber 
END
GO





