SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO

-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT02_DATAFINEVAL											 
-----------------------------------------------------------------------------------------'

IF NOT EXISTS(
    SELECT
        TOP 1 1
    FROM
        SYSCOLUMNS
    INNER JOIN SYSOBJECTS
	ON SYSOBJECTS.ID = SYSCOLUMNS.ID
    WHERE
        SYSCOLUMNS.NAME = 'GT02_DATAFINEVAL'
	AND SYSOBJECTS.NAME = 'GT02_CLIENTIFORNITORI'
)
	BEGIN
	   ALTER TABLE GT02_CLIENTIFORNITORI

		ADD GT02_DATAFINEVAL DATETIME NULL
		
	   PRINT 'Tabella GT02_CLIENTIFORNITORI: campo GT02_DATAFINEVAL creato'

	END
ELSE
	BEGIN
		PRINT 'Tabella GT02_CLIENTIFORNITORI: campo GT02_DATAFINEVAL esistente, creazione non effettuata'
	END
GO

-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT02_CLISOST
-----------------------------------------------------------------------------------------'

IF NOT EXISTS(
    SELECT
        TOP 1 1
    FROM
        SYSCOLUMNS
    INNER JOIN SYSOBJECTS
	ON SYSOBJECTS.ID = SYSCOLUMNS.ID
    WHERE
        SYSCOLUMNS.NAME = 'GT02_CLISOST'
	AND SYSOBJECTS.NAME = 'GT02_CLIENTIFORNITORI'
)
	BEGIN
	   ALTER TABLE GT02_CLIENTIFORNITORI

		ADD GT02_CLISOST INT NULL
		
	   PRINT 'Tabella GT02_CLIENTIFORNITORI: campo GT02_CLISOST creato'

	END
ELSE
	BEGIN
	PRINT 'Tabella GT02_CLIENTIFORNITORI: campo GT02_CLISOST esistente, creazione non effettuata'
	END
GO


-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT03_INDSOSPIMP
-----------------------------------------------------------------------------------------'

IF NOT EXISTS(
    SELECT
        TOP 1 1
    FROM
        SYSCOLUMNS
    INNER JOIN SYSOBJECTS
	ON SYSOBJECTS.ID = SYSCOLUMNS.ID
    WHERE
        SYSCOLUMNS.NAME = 'GT03_INDSOSPIMP'
	AND SYSOBJECTS.NAME = 'GT03_DOCTESTATA'
)
	BEGIN
	   ALTER TABLE GT03_DOCTESTATA

		ADD GT03_INDSOSPIMP TINYINT NULL
		
	   PRINT 'Tabella GT03_DOCTESTATA: campo GT03_INDSOSPIMP creato'

	END
ELSE
	BEGIN
	PRINT 'Tabella GT03_DOCTESTATA: campo GT03_INDSOSPIMP esistente, creazione non effettuata'
	END
GO



