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

-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT02_EMAIL_PEC											 
-----------------------------------------------------------------------------------------'

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

		ADD GT02_EMAIL_PEC varchar(128) NULL
		
	   PRINT 'Tabella GT02_CLIENTIFORNITORI: campo GT02_EMAIL_PEC creato'

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

-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT13_EMAIL_PEC											 
-----------------------------------------------------------------------------------------'

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

		ADD GT13_EMAIL_PEC nvarchar(128) NULL
		
	   PRINT 'Tabella GT13_DESTINATARI: campo GT13_EMAIL_PEC creato'

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


-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT11_EMAIL_PEC											 
-----------------------------------------------------------------------------------------'

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

		ADD GT11_EMAIL_PEC varchar(128) NULL
		
	   PRINT 'Tabella GT11_CONTATTI: campo GT11_EMAIL_PEC creato'

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

-----------------------------------------------------------------------------------------'
-- Aggiunta campo GT04_SYNCTU											 
-----------------------------------------------------------------------------------------'

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

		ADD GT04_SYNCTU tinyint NULL
		
	   PRINT 'Tabella GT04_DOCCORPO: campo GT04_SYNCTU creato'

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