﻿ALTER TABLE T_MUNKAUGYIADATOK NOCHECK CONSTRAINT all
ALTER TABLE T_TOVABBIMUNKAUGYIADATOK NOCHECK CONSTRAINT all
ALTER TABLE T_MUNKAIDOKEDVEZMENYOKA NOCHECK CONSTRAINT all

UPDATE T_DICTIONARYITEMBASE 
	SET TOROLT = 'T'
WHERE ID IN (3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3077)
	AND C_TYPE = 'MunkaidoKedvezmenyOka'

UPDATE T_MUNKAIDOKEDVEZMENYOKA 
	SET TOROLT = 'T'
WHERE ID IN (3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3077)

UPDATE T_MUNKAUGYIADATOK 
	SET C_MUNKAIDOKEDVEZMENYOKA = 3073
WHERE C_MUNKAIDOKEDVEZMENYOKA IS NOT NULL 
	AND C_MUNKAIDOKEDVEZMENYOKA IN (3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3077)

UPDATE T_TOVABBIMUNKAUGYIADATOK 
	SET C_MUNKAIDOKEDVEZMENYOKA = 3073
WHERE C_MUNKAIDOKEDVEZMENYOKA IS NOT NULL 
	AND C_MUNKAIDOKEDVEZMENYOKA IN (3061, 3062, 3063, 3064, 3065, 3066, 3067, 3068, 3077)

ALTER TABLE T_MUNKAUGYIADATOK WITH CHECK CHECK CONSTRAINT all
ALTER TABLE T_TOVABBIMUNKAUGYIADATOK WITH CHECK CHECK CONSTRAINT all
ALTER TABLE T_MUNKAIDOKEDVEZMENYOKA WITH CHECK CHECK CONSTRAINT all


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  
	PRINT N'INTÉZMÉNY ID: ' + CAST(@intezmenyId AS NVARCHAR(10)) + N', TANÉV ID: ' + CAST(@tanevId AS NVARCHAR(10))
    EXEC sp_Global_CreateDictionaryItems @IntezmenyId = @intezmenyId, @TanevId = @tanevId

	FETCH NEXT FROM intezmenytanevekCursor INTO @intezmenyId, @tanevId
END  

CLOSE intezmenytanevekCursor  
DEALLOCATE intezmenytanevekCursor

GO
