SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE   PROCEDURE [batch].[Update_Mitarbeiter]
AS
BEGIN

    MERGE INTO [GC_CONFIG].[ari].[Mitarbeiter]
        AS
        [dest]
    USING
        [GC_ETL_ARI].[transform_config].[Mitarbeiter]
            AS
            [source]
    ON
        [dest].[Client_DB] = [source].[Client_DB]
            AND [dest].[Employee No_] = [source].[Employee No_]
    WHEN
        MATCHED
        THEN
        UPDATE
        SET [dest].[Name]            = [source].[Name]
          , [dest].[First Name]      = [source].[First Name]
          , [dest].[Last Name]       = [source].[Last Name]
          , [dest].[Employment Date] = [source].[Employment Date]
          , [dest].[Leaving Date]    = [source].[Leaving Date]
          , [dest].[Task Type Group] = [source].[Task Type Group]
          , [dest].[Function Code]   = [source].[Function Code]
          , [dest].[Group No_ 1]     = [source].[Group No_ 1]
          , [dest].[Group No_ 2]     = [source].[Group No_ 2]
          , [dest].[Group No_ 3]     = [source].[Group No_ 3]
          , [dest].[aktiv]           = [source].[aktiv]

    WHEN
        NOT
        MATCHED
        THEN
        INSERT
        ( [Client_DB]
        , [Employee No_]
        , [Name]
        , [First Name]
        , [Last Name]
        , [Employment Date]
        , [Leaving Date]
        , [Task Type Group]
        , [Function Code]
        , [Group No_ 1]
        , [Group No_ 2]
        , [Group No_ 3]
        , [aktiv]
        , [Erstellungsdatum]
        , [Monteur_Gruppe]
        , [Monteur_Gruppe_2])
        VALUES ( [source].[Client_DB]
               , [source].[Employee No_]
               , [source].[Name]
               , [source].[First Name]
               , [source].[Last Name]
               , [source].[Employment Date]
               , [source].[Leaving Date]
               , [source].[Task Type Group]
               , [source].[Function Code]
               , [source].[Group No_ 1]
               , [source].[Group No_ 2]
               , [source].[Group No_ 3]
               , [source].[aktiv]
               , [source].[Erstellungsdatum]
               , [source].[Monteur_Gruppe]
               , [source].[Monteur_Gruppe_2]);

END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
