﻿--Migration
DECLARE IntCursor CURSOR LOCAL FOR
SELECT i.ID, tv.ID
FROM T_INTEZMENY i
  INNER JOIN T_TANEV tv ON tv.C_INTEZMENYID = i.ID
WHERE tv.C_AKTIV = 'T' AND tv.TOROLT = 'F'
  AND i.TOROLT = 'F'

DECLARE @intezmenyId int, @tanevId int

OPEN IntCursor
FETCH NEXT FROM IntCursor INTO @intezmenyId, @tanevId


WHILE @@fetch_status = 0 BEGIN
  EXEC uspGenerateOrarend
   @pIntezmenyId = @intezmenyId
  ,@pTanevId = @tanevId

  FETCH NEXT FROM IntCursor INTO @intezmenyId, @tanevId
END

CLOSE IntCursor
DEALLOCATE IntCursor