﻿SET DATEFIRST 1

UPDATE nn
SET C_HETIREND = C_ALAPHETIREND
  , C_HETNAPJA = C_ALAPHETNAPJA
  , C_NAPTIPUSA = C_ALAPNAPTIPUSA
  , C_ORARENDINAP = C_ALAPORARENDINAP
  , C_AKTIVCSENGETESIRENDID = C_ALAPCSENGETESIRENDID
FROM T_NAPTARINAP nn 
WHERE NOT EXISTS (SELECT 1 FROM T_TANEVRENDJE tr WHERE tr.C_DATUM = nn.C_NAPDATUMA AND tr.C_INTEZMENYID = nn.C_INTEZMENYID AND tr.C_TANEVID = nn.C_TANEVID AND tr.C_OSSZESCSOPORTRAVONATKOZIK = 'T' AND tr.TOROLT = 'F')
AND DATEPART(dw, nn.C_NAPDATUMA) IN (6,7)
AND nn.C_ORARENDINAP = 'T'
AND nn.C_ALAPORARENDINAP = 'F'
