﻿DECLARE intezmenytanevekCursor CURSOR LOCAL FOR 
	SELECT C_INTEZMENYID, C_TANEVID
		FROM T_INTEZMENYADATOK

DECLARE @intezmenyId int, @tanevId int

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

WHILE @@FETCH_STATUS = 0 
BEGIN  
	DECLARE @ertek nvarchar(max) = (SELECT C_ERTEK FROM T_RENDSZERBEALLITAS WHERE C_BEALLITASTIPUS = 7375 AND C_INTEZMENYID = @intezmenyId AND C_TANEVID = @tanevId AND TOROLT = 'F')
	DECLARE @alapErtek nvarchar(max) = (SELECT C_ALAPERTEK FROM T_RENDSZERBEALLITAS WHERE C_BEALLITASTIPUS = 7375 AND C_INTEZMENYID = @intezmenyId AND C_TANEVID = @tanevId AND TOROLT = 'F')

	SET @ertek = JSON_MODIFY(@ertek,'$.Value', 'true')
	SET @alapErtek = JSON_MODIFY(@alapErtek,'$.Value', 'true')

	UPDATE T_RENDSZERBEALLITAS
	SET C_ERTEK = @ertek
	   ,C_ALAPERTEK = @alapErtek
	WHERE C_BEALLITASTIPUS = 7375 AND C_INTEZMENYID = @intezmenyId AND C_TANEVID = @tanevId AND TOROLT = 'F'

	FETCH NEXT FROM intezmenytanevekCursor INTO @intezmenyId, @tanevId
END  

CLOSE intezmenytanevekCursor  
DEALLOCATE intezmenytanevekCursor




