﻿
DROP TABLE IF EXISTS tmpForSwitchDictionaryItemBase 
CREATE TABLE tmpForSwitchDictionaryItemBase(RegiID int, UjID int, TanevID int, C_NAME nvarchar(500), C_TYPE nvarchar(64), Torolni char(1))
DECLARE @TEMP_EnvironmentName nvarchar(1000), @TanevSorszam int, @LastTanevSorszam int
SET @LastTanevSorszam  = (SELECT MAX(C_SORSZAM) FROM T_TANEV WHERE TOROLT = 'F' AND (C_KOVETKEZO = 'T' OR C_AKTIV = 'T'))
SET @TanevSorszam = ISNULL((SELECT TOP 1 C_SORSZAM FROM T_TANEV WHERE C_NEV = '2021/2022' ORDER BY C_SORSZAM),32)
SET @TEMP_EnvironmentName = (SELECT [Value] 
FROM dev.EnvironmentInfo WHERE [Key] = 'Dictionary')
IF (@TEMP_EnvironmentName IS NULL OR @TEMP_EnvironmentName NOT IN ('KK','NSZFH','HOI','AZURE'))
BEGIN  INSERT INTO T_DICTIONARYITEMBASE(C_VALUE) VALUES('Nincs Dictionary ertek a dev.EnvironmentInfo tablaban') END  -- elszall a migracio ha nincs 
 IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 9075, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 185 AND DIB.C_NAME = N'Egyéb foglalkoztató' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 185 AND DIB.C_NAME = N'Egyéb foglalkoztató' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'Egyéb foglalkoztató' 
    ,DIB.C_NAME_1 = N'Egyéb foglalkoztató' 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 9075;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 9075, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 185 AND DIB.C_NAME = N'Egyéb foglalkoztató' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 185 AND DIB.C_NAME = N'Egyéb foglalkoztató' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'Egyéb foglalkoztató' 
    ,DIB.C_NAME_1 = N'Egyéb foglalkoztató' 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 9075;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 9075, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 185 AND DIB.C_NAME = N'Egyéb foglalkoztató' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 185 AND DIB.C_NAME = N'Egyéb foglalkoztató' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'Egyéb foglalkoztató' 
    ,DIB.C_NAME_1 = N'Egyéb foglalkoztató' 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 9075;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 9075, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 185 AND DIB.C_NAME = N'Egyéb foglalkoztató' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 185 AND DIB.C_NAME = N'Egyéb foglalkoztató' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME = N'Egyéb foglalkoztató' 
    ,DIB.C_NAME_1 = N'Egyéb foglalkoztató' 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 9075;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 8827, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Munkarend nélküli oktatás' 
    ,DIB.C_ORDER = 80 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 8827;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 8827, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Munkarend nélküli oktatás' 
    ,DIB.C_ORDER = 80 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 8827;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 8827, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Munkarend nélküli oktatás' 
    ,DIB.C_ORDER = 80 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 8827;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 8827, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Munkarend nélküli oktatás' 
    ,DIB.C_ORDER = 80 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 8827;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1095, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 1 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1095;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1095, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 1 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1095;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1095, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 1 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1095;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1095, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 1 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1095;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1096, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 10 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1096;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1096, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 10 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1096;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1096, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 10 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1096;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1096, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 10 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1096;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1097, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 20 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1097;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1097, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 20 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1097;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1097, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 20 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1097;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1097, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 20 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1097;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1099, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 90 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1099;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1099, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 90 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1099;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1099, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 90 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1099;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1099, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 90 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1099;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1103, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 30 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1103;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1103, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 30 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1103;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1103, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 30 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1103;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1103, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 30 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1103;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1101, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 240 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1101;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1101, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 240 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1101;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1101, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 240 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1101;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1101, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 240 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1101;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5446, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Esti rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 60 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5446;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5446, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Esti rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 60 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5446;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5446, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Esti rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 60 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5446;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5446, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Esti rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 60 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5446;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5447, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Levelező rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 70 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5447;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5447, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Levelező rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 70 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5447;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5447, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Levelező rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 70 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5447;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5447, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Levelező rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 70 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5447;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5445, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Nappali rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 50 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5445;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5445, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Nappali rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 50 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5445;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5445, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Nappali rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 50 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5445;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5445, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'Nappali rendszerű felnőttoktatás' 
    ,DIB.C_ORDER = 50 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5445;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1102, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 220 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1102;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1102, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 220 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1102;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1102, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 220 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1102;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1102, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 220 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1102;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1104, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 40 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1104;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1104, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 40 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1104;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1104, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 40 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1104;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1104, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 40 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1104;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1098, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 100 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1098;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1098, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 100 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1098;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1098, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 100 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1098;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1098, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 100 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1098;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5448, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 210 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5448;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5448, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 210 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5448;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5448, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 210 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5448;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 5448, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 210 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 5448;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1100, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 230 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1100;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1100, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 230 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1100;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1100, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 230 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1100;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1100, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 230 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1100;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1105, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 200 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1105;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1105, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 200 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1105;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1105, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 200 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1105;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE, Torolni) 
  SELECT DIB.ID, 1105, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE, 'F' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET 
    DIB.TOROLT = 'T' 
  FROM T_DICTIONARYITEMBASE DIB INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.C_DICTIONARYTYPEID = 27 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_ORDER = 200 
  FROM T_DICTIONARYITEMBASE DIB 
  INNER JOIN T_TANEV t ON t.ID = DIB.C_TANEVID AND t.TOROLT = 'F' AND t.C_SORSZAM >= @TanevSorszam AND t.C_SORSZAM <= @LastTanevSorszam 
    WHERE DIB.ID = 1105;
  END;
 DISABLE TRIGGER ALL ON T_DICTIONARYITEMBASE;  
 EXEC [dev].[uspCreateDictionaryItems] NULL, NULL; 
 ENABLE TRIGGER ALL ON T_DICTIONARYITEMBASE;  
 EXEC [dev].uspSwitchDictionaryItemBaseFromTmp;  

UPDATE dib SET
    dib.TOROLT = IIF(ia.C_ISSZAKKEPZO = 'T','F','T') 
  FROM T_DICTIONARYITEMBASE_OSSZES dib
  INNER JOIN T_INTEZMENYADATOK_OSSZES ia ON ia.C_TANEVID = DIB.C_TANEVID
  WHERE dib.ID IN(8999,9000)










