﻿--csoporttípus szinkron
UPDATE cstNew SET
   C_ISTANORAICELU = cstOld.C_ISTANORAICELU
  ,MODIFIER = 0
  ,LASTCHANGED = GETDATE()
FROM T_CSOPORTTIPUS cstNew
	INNER JOIN T_TANEV tnNew ON tnNew.ID = cstNew.C_ALTANEVID AND tnNew.TOROLT='F' AND tnNew.C_NEV = '2020/2021'
		AND tnNew.C_KOVETKEZO = 'T'
	INNER JOIN T_CSOPORTTIPUS cstOld ON cstOld.ID = cstNew.ELOZOTANEVIREKORDID
		AND cstOld.C_ISTANORAICELU <>cstNew.C_ISTANORAICELU AND cstOld.TOROLT='F'
	INNER JOIN T_TANEV tnOld ON tnOld.C_INTEZMENYID = tnNew.C_INTEZMENYID AND tnOld.ID = cstOld.C_ALTANEVID
		AND tnOld.C_AKTIV ='T' AND tnOld.C_NEV = '2019/2020' AND tnOld.TOROLT='F'
WHERE cstNew.TOROLT='F'