-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT04_DADATACOMP
-----------------------------------------------------------------------------------------'

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

		ADD GT04_DADATACOMP datetime NULL
		
	   PRINT 'Tabella GT04_DOCCORPO: campo GT04_DADATACOMP creato'

	END
ELSE
	BEGIN
	PRINT 'Tabella GT04_DOCCORPO: campo GT04_DADATACOMP esistente, creazione non effettuata'
	END
GO

-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT04_ADATACOMP
-----------------------------------------------------------------------------------------'

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

		ADD GT04_ADATACOMP datetime NULL
		
	   PRINT 'Tabella GT04_DOCCORPO: campo GT04_ADATACOMP creato'

	END
ELSE
	BEGIN
	PRINT 'Tabella GT04_DOCCORPO: campo GT04_ADATACOMP esistente, creazione non effettuata'
	END
GO

-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT03_SCIMPMERCE
-----------------------------------------------------------------------------------------'

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

		ADD GT03_SCIMPMERCE decimal(10,2) NULL
		
	   PRINT 'Tabella GT03_DOCTESTATA: campo GT03_SCIMPMERCE creato'

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


-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT03_SCPERMERCE1
-----------------------------------------------------------------------------------------'

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

		ADD GT03_SCPERMERCE1 decimal(6,3) NULL
		
	   PRINT 'Tabella GT03_DOCTESTATA: campo GT03_SCPERMERCE1 creato'

	END
ELSE
	BEGIN
	PRINT 'Tabella GT03_SCIMPMERCE: campo GT03_SCPERMERCE1 esistente, creazione non effettuata'
	END
GO