﻿--Migration
UPDATE mhNEW
SET mhNEW.C_MUKODESIHELYTIPUSA = mhOLD.C_MUKODESIHELYTIPUSA
   ,mhNEW.MODIFIER = 0
   ,mhNEW.LASTCHANGED = GETDATE()
   ,mhNEW.SERIAL += 1
from T_MUKODESIHELY mhOLD
inner join T_MUKODESIHELY mhNEW on mhNEW.ELOZOTANEVIREKORDID = mhOLD.ID AND mhNEW.TOROLT = 'F'
inner join T_TANEV te on te.ID = mhNEW.C_TANEVID and te.TOROLT = 'F' and te.C_NEV = '2022/2023'
where mhOLD.C_MUKODESIHELYTIPUSA <> mhNEW.C_MUKODESIHELYTIPUSA
  and mhNEW.SERIAL < 2
  and mhNEW.C_MUKODESIHELYTIPUSA = 5432
