@echo off call "C:\GlobalCube\Tasks\scripts\config2.bat" rem ==CALENDAR_EVENT== del C:\GlobalCube\System\OPTIMA\SQL\logs\CALENDAR_EVENT*.* /Q /F >nul 2>nul if not "%1"=="" goto :increment :full call sql_query.bat "TRUNCATE TABLE [OPTIMA].[import].[CALENDAR_EVENT]" rem Nur in Quelle: CREATION_DATETIME call bcp_queryout.bat "CALENDAR_EVENT_1" "SELECT T1.[CALENDAR_EVENT_NAME], T1.[EVENT_START], T1.[EVENT_END], T1.[OCCURRENCE], T1.[ALL_DAY_EVENT], T1.[RECURRING_PATTERN_ID], T1.[ACTIVITY_ID], T1.[CALENDAR_INFO_ID], T1.[CALENDAR_TYPE_ID], T1.[RECURRING_TYPE_ID], T1.[HOLIDAY_ID], T1.[TRANSACT_DATE], T1.[HANDLER], T1.[PROGRAM], T1.[FUNCTION_CODE], T1.[CONV_FLAG], T1.[timestamp], T1.[UNIQUE_ID], '1' as [Client_DB] FROM [deop01].[dbo].[CALENDAR_EVENT] T1 WHERE 1 = 1 ORDER BY T1.[timestamp] " call bcp_in.bat "CALENDAR_EVENT_1" "[import].[CALENDAR_EVENT]" "OPTIMA" rem Nur in Quelle: CREATION_DATETIME call bcp_queryout.bat "CALENDAR_EVENT_2" "SELECT T1.[CALENDAR_EVENT_NAME], T1.[EVENT_START], T1.[EVENT_END], T1.[OCCURRENCE], T1.[ALL_DAY_EVENT], T1.[RECURRING_PATTERN_ID], T1.[ACTIVITY_ID], T1.[CALENDAR_INFO_ID], T1.[CALENDAR_TYPE_ID], T1.[RECURRING_TYPE_ID], T1.[HOLIDAY_ID], T1.[TRANSACT_DATE], T1.[HANDLER], T1.[PROGRAM], T1.[FUNCTION_CODE], T1.[CONV_FLAG], T1.[timestamp], T1.[UNIQUE_ID], '2' as [Client_DB] FROM [deop02].[dbo].[CALENDAR_EVENT] T1 WHERE 1 = 1 ORDER BY T1.[timestamp] " call bcp_in.bat "CALENDAR_EVENT_2" "[import].[CALENDAR_EVENT]" "OPTIMA" goto :cleanup :increment call sql_query.bat "TRUNCATE TABLE [OPTIMAX].[temp].[CALENDAR_EVENT]" call sql_timestamp.bat "CALENDAR_EVENT_1" "[OPTIMA].[import].[CALENDAR_EVENT]" "1" call bcp_queryout.bat "CALENDAR_EVENT_1" "SELECT T1.[CALENDAR_EVENT_NAME], T1.[EVENT_START], T1.[EVENT_END], T1.[OCCURRENCE], T1.[ALL_DAY_EVENT], T1.[RECURRING_PATTERN_ID], T1.[ACTIVITY_ID], T1.[CALENDAR_INFO_ID], T1.[CALENDAR_TYPE_ID], T1.[RECURRING_TYPE_ID], T1.[HOLIDAY_ID], T1.[TRANSACT_DATE], T1.[HANDLER], T1.[PROGRAM], T1.[FUNCTION_CODE], T1.[CONV_FLAG], T1.[timestamp], T1.[UNIQUE_ID], '1' as [Client_DB] FROM [deop01].[dbo].[CALENDAR_EVENT] T1 WHERE T1.[timestamp] > convert(binary(8), '%TS%', 1) AND 1 = 1 ORDER BY T1.[timestamp] " call bcp_in.bat "CALENDAR_EVENT_1" "[temp].[CALENDAR_EVENT]" "OPTIMAX" call sql_timestamp.bat "CALENDAR_EVENT_2" "[OPTIMA].[import].[CALENDAR_EVENT]" "2" call bcp_queryout.bat "CALENDAR_EVENT_2" "SELECT T1.[CALENDAR_EVENT_NAME], T1.[EVENT_START], T1.[EVENT_END], T1.[OCCURRENCE], T1.[ALL_DAY_EVENT], T1.[RECURRING_PATTERN_ID], T1.[ACTIVITY_ID], T1.[CALENDAR_INFO_ID], T1.[CALENDAR_TYPE_ID], T1.[RECURRING_TYPE_ID], T1.[HOLIDAY_ID], T1.[TRANSACT_DATE], T1.[HANDLER], T1.[PROGRAM], T1.[FUNCTION_CODE], T1.[CONV_FLAG], T1.[timestamp], T1.[UNIQUE_ID], '2' as [Client_DB] FROM [deop02].[dbo].[CALENDAR_EVENT] T1 WHERE T1.[timestamp] > convert(binary(8), '%TS%', 1) AND 1 = 1 ORDER BY T1.[timestamp] " call bcp_in.bat "CALENDAR_EVENT_2" "[temp].[CALENDAR_EVENT]" "OPTIMAX" call sql_query.bat "DELETE T1 FROM [OPTIMA].[import].[CALENDAR_EVENT] T1 INNER JOIN [OPTIMAX].[temp].[CALENDAR_EVENT] T2 ON T1.[CLIENT_DB] = T2.[CLIENT_DB] AND T1.[UNIQUE_ID] = T2.[UNIQUE_ID]" call sql_query.bat "INSERT INTO [OPTIMA].[import].[CALENDAR_EVENT] with (TABLOCK) SELECT * FROM [OPTIMAX].[temp].[CALENDAR_EVENT] T1" :cleanup call delete.bat "C:\GlobalCube\System\OPTIMA\SQL\temp\CALENDAR_EVENT_1.csv" call delete.bat "C:\GlobalCube\System\OPTIMA\SQL\temp\CALENDAR_EVENT_2.csv"