UPDATE TBDD_MODULES SET DB_VERSION = '2.5.3.0' where NAME = 'Global-Indexer' and DB_VERSION <> '2.5.3.0'
GO
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'VKT_PREVENT_MULTIPLE_VALUES' AND Object_ID = Object_ID(N'dbo.TBDD_INDEX_AUTOM'))
	BEGIN
		ALTER TABLE TBDD_INDEX_AUTOM ADD VKT_PREVENT_MULTIPLE_VALUES bit NOT NULL DEFAULT 0
	END
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'VKT_OVERWRITE' AND Object_ID = Object_ID(N'dbo.TBDD_INDEX_AUTOM'))
	BEGIN
		ALTER TABLE TBDD_INDEX_AUTOM ADD VKT_OVERWRITE bit NOT NULL DEFAULT 0
	END
GO
CREATE OR ALTER VIEW [dbo].[VWDDINDEX_AUTOM]
AS
SELECT TOP 100 PERCENT
     T.GUID,
     T.INDEXNAME,
     T.COMMENT,
     T.DOCTYPE_ID,
     T1.BEZEICHNUNG	    DOKUMENTART,
     T1.KURZNAME,
     T.CONNECTION_ID,
     T2.BEZEICHNUNG		CONNECTION,
     T2.SQL_PROVIDER,
     T2.SERVER,
     T2.DATENBANK,
     T2.USERNAME,
     T2.PASSWORD,
     T.SQL_RESULT,
	 T.SQL_ACTIVE,
	 T.VALUE,
     T.[SEQUENCE],
	 T.VKT_OVERWRITE,
	 T.VKT_PREVENT_MULTIPLE_VALUES
FROM
	TBDD_INDEX_AUTOM			T
	INNER JOIN TBDD_DOKUMENTART	T1 ON T.DOCTYPE_ID = T1.GUID AND T1.AKTIV = 1
	LEFT  JOIN TBDD_CONNECTION	T2 ON T.CONNECTION_ID = T2.GUID	AND T2.AKTIV = 1
WHERE 
	T.ACTIVE = 1
ORDER BY
	 T.DOCTYPE_ID,
	 T.GUID

GO

