﻿IF OBJECT_ID('stage.fnGetPedagogusIKTAdatszolgaltatas') IS NOT NULL BEGIN
  DROP FUNCTION stage.fnGetPedagogusIKTAdatszolgaltatas 
END
GO

CREATE FUNCTION stage.fnGetPedagogusIKTAdatszolgaltatas (
  @lastLoad datetime
) RETURNS xml AS 
BEGIN
  DECLARE @xml xml
  SET @xml = (
    SELECT
       i.C_AZONOSITO AS intezmenyAzonosito
      ,s.C_TANEVNEV AS tanevNev
      ,s.C_PEDAGOGUSIKTID AS pedagogusIKTId
      ,s.C_ALKALMAZOTTID AS alkalmazottId
      ,s.C_ELSODLEGESIKTESZKOZE AS elsodlegesIKTEszkoze
      ,s.C_IKTESZKOZHASZNALATMODJA AS iKTEszkozHasznalatModja
      ,s.C_IKTKOMPETENCIASZINTJE AS iKTKompetenciaSzintje
      ,s.TOROLT AS torolt
    FROM stage.T_PEDAGOGUSIKT_STAGE s
      INNER JOIN dbo.T_INTEZMENY i ON i.ID = s.C_INTEZMENYID
    WHERE s.LASTCHANGED > @lastLoad
    FOR XML RAW ('PedagogusIKTAdatszolgaltatas'), ROOT('PedagogusIKTAdatszolgaltatasItems')
  );

  RETURN @xml

END;
GO
