﻿DECLARE intezmenytanevekCursor CURSOR LOCAL FOR 
	SELECT ia.C_INTEZMENYID, ia.C_TANEVID
		FROM T_INTEZMENYADATOK ia
	JOIN T_TANEV t on t.ID = ia.C_TANEVID and t.TOROLT = 'F'
DECLARE @intezmenyId int, @tanevId int

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

WHILE @@FETCH_STATUS = 0 
BEGIN  
	PRINT 'INTÉZMÉNY ID: ' + CAST(@intezmenyId AS NVARCHAR(10)) + ', TANÉV ID: ' + CAST(@tanevId AS NVARCHAR(10))
    EXEC sp_Global_SetSystemSettingsDefaultData @IntezmenyId = @intezmenyId, @TanevId = @tanevId

	FETCH NEXT FROM intezmenytanevekCursor INTO @intezmenyId, @tanevId
END  

CLOSE intezmenytanevekCursor  
DEALLOCATE intezmenytanevekCursor 

