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

UPDATE T_MUNKAUGYIADATOK 
	SET C_KEPESITES = 3040
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 6462

UPDATE T_MUNKAUGYIADATOK 
	SET C_KEPESITES = 3044
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1566

UPDATE T_MUNKAUGYIADATOK 
	SET C_KEPESITES = 3045
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1567

UPDATE T_MUNKAUGYIADATOK 
	SET C_KEPESITES = 3046
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1568

UPDATE T_MUNKAUGYIADATOK 
	SET C_KEPESITES = 3047
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1570

UPDATE T_MUNKAUGYIADATOK 
	SET C_KEPESITES = 3048
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1569

UPDATE T_MUNKAUGYIADATOK 
	SET C_KEPESITES = 3040
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES NOT IN (3044, 3045, 3046, 3047, 3048)


UPDATE T_TOVABBIMUNKAUGYIADATOK 
	SET C_KEPESITES = 3040
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 6462

UPDATE T_TOVABBIMUNKAUGYIADATOK 
	SET C_KEPESITES = 3044
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1566

UPDATE T_TOVABBIMUNKAUGYIADATOK 
	SET C_KEPESITES = 3045
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1567

UPDATE T_TOVABBIMUNKAUGYIADATOK 
	SET C_KEPESITES = 3046
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1568

UPDATE T_TOVABBIMUNKAUGYIADATOK 
	SET C_KEPESITES = 3047
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1570

UPDATE T_TOVABBIMUNKAUGYIADATOK 
	SET C_KEPESITES = 3048
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES = 1569

UPDATE T_TOVABBIMUNKAUGYIADATOK 
	SET C_KEPESITES = 3040
WHERE C_KEPESITES IS NOT NULL 
AND C_KEPESITES NOT IN (3044, 3045, 3046, 3047, 3048)

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

DELETE FROM T_DICTIONARYITEMBASE
WHERE C_TYPE = 'Kepesites'

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
