﻿UPDATE T_TANEVRENDJE 
SET C_DATUM = '20181231' 
WHERE C_DATUM = '20171231' 
  AND C_TANEVID IN (SELECT ID FROM T_TANEV WHERE C_NEV = '2018/2019')

UPDATE nn SET
   nn.C_HETNAPJA = ISNULL(tr.C_HETNAPJA, nn.C_HETNAPJA)
  ,nn.C_NAPTIPUSA = tr.C_NAPTIPUSA
  ,nn.C_ORARENDINAP = tr.C_ORARENDINAP
  ,nn.C_ALAPHETNAPJA = ISNULL(tr.C_HETNAPJA, nn.C_ALAPHETNAPJA)
  ,nn.C_ALAPNAPTIPUSA = tr.C_NAPTIPUSA
  ,nn.C_ALAPORARENDINAP = tr.C_ORARENDINAP
FROM T_NAPTARINAP nn
  INNER JOIN T_TANEVRENDJE tr ON nn.C_INTEZMENYID = tr.C_INTEZMENYID AND nn.C_TANEVID = tr.C_TANEVID AND nn.C_NAPDATUMA = tr.C_DATUM AND tr.TOROLT = 'F'
  INNER JOIN T_TANEV te ON te.ID = nn.C_TANEVID AND te.C_NEV = '2018/2019' AND te.TOROLT = 'F'
WHERE tr.C_OSSZESCSOPORTRAVONATKOZIK = 'T' 
  AND nn.TOROLT = 'F'
  AND tr.C_DATUM = '20181231'
GO

UPDATE T_TANEVRENDJE SET C_ORARENDINAP = 'T'
WHERE C_NAPTIPUSA IN (1394, 1395)
  AND C_TANEVID IN (SELECT ID FROM T_TANEV WHERE C_NEV = '2018/2019')
  
UPDATE T_NAPTARINAP SET
   C_ORARENDINAP = 'T'
  ,C_ALAPORARENDINAP = 'T'
WHERE C_NAPTIPUSA IN (1394, 1395)
  AND C_TANEVID IN (SELECT ID FROM T_TANEV WHERE C_NEV = '2018/2019')
GO
  
  
