﻿
DROP TABLE IF EXISTS tmpForSwitchDictionaryItemBase 
CREATE TABLE tmpForSwitchDictionaryItemBase(RegiID int, UjID int, TanevID int, C_NAME nvarchar(500), C_TYPE nvarchar(64))
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 = '2020/2021' 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) 
  SELECT DIB.ID, 7865, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'4/12' 
  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 = 7865;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7865, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'4/12' 
  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 = 7865;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7865, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'4/12' 
  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 = 7865;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7865, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'4/12' 
  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 = 7865;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7868, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'9/Oe' 
  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 = 7868;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7868, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'9/Oe' 
  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 = 7868;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7868, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'9/Oe' 
  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 = 7868;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7868, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'9/Oe' 
  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 = 7868;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7879, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'13.' 
  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 = 7879;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7879, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'13.' 
  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 = 7879;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7879, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'13.' 
  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 = 7879;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7879, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'13.' 
  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 = 7879;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7880, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'13.' 
  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 = 7880;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7880, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'13.' 
  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 = 7880;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7880, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'13.' 
  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 = 7880;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7880, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'13.' 
  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 = 7880;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7881, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'14.' 
  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 = 7881;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7881, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'14.' 
  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 = 7881;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7881, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'14.' 
  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 = 7881;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7881, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'14.' 
  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 = 7881;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7882, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'14.' 
  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 = 7882;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7882, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'14.' 
  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 = 7882;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7882, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'14.' 
  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 = 7882;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7882, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'14.' 
  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 = 7882;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7889, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'M' 
  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 = 7889;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7889, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'M' 
  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 = 7889;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7889, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'M' 
  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 = 7889;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7889, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'M' 
  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 = 7889;
  END IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7904, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'E/D' 
  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 = 7904;
  END IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7904, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'E/D' 
  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 = 7904;
  END IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7904, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'E/D' 
  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 = 7904;
  END IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
  INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE) 
  SELECT DIB.ID, 7904, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE 
  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 = 37 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 = 37 AND DIB.C_NAME = N'' AND DIB.TOROLT = 'F' 
  UPDATE DIB SET DIB.TOROLT = 'F'     ,DIB.C_NAME_1 = N'E/D' 
  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 = 7904;
  END;
 DISABLE TRIGGER ALL ON T_DICTIONARYITEMBASE;  
 EXEC [dev].[uspCreateDictionaryItems] NULL, NULL; 
 ENABLE TRIGGER ALL ON T_DICTIONARYITEMBASE;  
 EXEC [dev].uspSwitchDictionaryItemBaseFromTmp;  


