﻿--Migration
DECLARE intezmenytanevekCursor CURSOR LOCAL FOR 
  SELECT IntezmenyAdatok.C_INTEZMENYID
        ,IntezmenyAdatok.C_TANEVID
  FROM T_INTEZMENYADATOK IntezmenyAdatok
  INNER JOIN T_TANEV Tanev ON Tanev.ID = C_TANEVID AND Tanev.TOROLT = 'F' AND Tanev.C_AKTIV = 'T'

DECLARE @intezmenyId int, @tanevId int

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

WHILE @@FETCH_STATUS = 0 
BEGIN  
  EXECUTE dbo.uspGenerateTeljesOrarend @pIntezmenyId = @intezmenyId, @pTanevId = @tanevId
  
  FETCH NEXT FROM intezmenytanevekCursor INTO @intezmenyId, @tanevId
END

CLOSE intezmenytanevekCursor  
DEALLOCATE intezmenytanevekCursor