PRINT N'Altering [dbo].[pal_Sales]...';

IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'dateDue'
      AND Object_ID = Object_ID(N'pal_Sales'))
BEGIN
ALTER TABLE [dbo].[pal_Sales]
    ADD [dateDue]   DATETIME      NULL;
END

IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'vatNum'
      AND Object_ID = Object_ID(N'pal_Sales'))
BEGIN
ALTER TABLE [dbo].[pal_Sales]
    ADD [vatNum]    VARCHAR (100) NULL;
END

IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'accountNo'
      AND Object_ID = Object_ID(N'pal_Sales'))
BEGIN
ALTER TABLE [dbo].[pal_Sales]
    ADD [accountNo] VARCHAR (100) NULL;
END


IF EXISTS(select * FROM sys.views where name = 'v_SalesView')
BEGIN
DROP VIEW v_SalesView
END