﻿IF DB_NAME() LIKE '%KRETA_KLIK%'
BEGIN
  UPDATE fhNew set C_KKKEPESITESID=fhOld.C_KKKEPESITESID
	FROM T_ALKALMAZOTT fhNew
		INNER JOIN T_TANEV tn ON tn.C_NEV='2018/2019' AND tn.ID=fhNew.C_ALTANEVID
		INNER JOIN T_ALKALMAZOTT fhOld ON fhOld.ID=fhNew.ELOZOTANEVIREKORDIDA AND fhOld.TOROLT='F' AND fhOld.C_KKKEPESITESID IS NOT NULL
	WHERE fhNew.TOROLT='F' AND fhNew.C_KKKEPESITESID IS NULL
END