update tcs set TOROLT = 'T', MODIFIER = 0, LASTCHANGED = GETDATE(), SERIAL += 1 --select te.C_NEV, i.C_AZONOSITO, tcs.ID, tcs.C_TANEVID, tcs.C_INTEZMENYID--, * from T_TANULOCSOPORT tcs inner join T_OSZTALYCSOPORT ocs on ocs.ID = tcs.C_OSZTALYCSOPORTID and ocs.TOROLT = 'F' inner join T_OSZTALY o on o.ID = ocs.ID and o.TOROLT = 'F' inner join T_TANEV te on te.ID = tcs.C_TANEVID and te.TOROLT = 'F' and te.C_KOVETKEZO = 'T' inner join T_INTEZMENY i on i.ID = tcs.C_INTEZMENYID and i.torolt = 'F' where not exists (select 1 from T_TANULOTANUGYIADATOK tta where tta.C_TANULOCSOPORTID = tcs.ID) ------------------------------------------- update tcs set TOROLT = 'T', MODIFIER = 0, LASTCHANGED = GETDATE(), SERIAL += 1 --select te.C_NEV, i.C_AZONOSITO, tcs.ID as tcsID, t.ID as tanID--, * from T_TANULOCSOPORT tcs inner join T_TANULO t on t.ID = tcs.C_TANULOID inner join T_TANEV te on te.ID = tcs.C_TANEVID and te.TOROLT = 'F' and te.C_KOVETKEZO = 'T' inner join T_INTEZMENY i on i.ID = tcs.C_INTEZMENYID and i.TOROLT = 'F' where tcs.TOROLT = 'F' and t.TOROLT = 'T'