DROP PROCEDURE IF EXISTS uspGetAktualisGondviseloCimekEugyintezes
GO
  CREATE PROCEDURE uspGetAktualisGondviseloCimekEugyintezes
     @pGondviseloId INT
    ,@pTanevId INT
  AS
  BEGIN
    SET NOCOUNT ON;

    SELECT c.ID AS KretaAzonosito
      ,c.C_CIMTIPUSA AS TipusKod
      ,ct.C_NAME AS TipusMegnevezes
      ,c.C_IRANYITOSZAM AS Iranyitoszam
      ,c.C_VAROS AS Helyseg
      ,c.C_KOZTERULET AS KozteruletNeve
      ,c.C_KOZTERULETJELLEGENEV AS KozteruletJellegeNev
      ,c.C_HAZSZAM AS Hazszam
      ,c.C_EMELET AS Emelet
      ,c.C_AJTO AS Ajto
      ,c.C_ORSZAG AS OrszagId
      ,iso.C_ISOKOD AS Isokod
      ,orszag.C_NAME AS Orszag
    FROM T_CIM_OSSZES c
    LEFT JOIN T_DICTIONARYITEMBASE_OSSZES ct ON ct.ID = c.C_CIMTIPUSA
      AND ct.TOROLT = 'F'
      AND ct.C_TANEVID = c.C_TANEVID
    INNER JOIN T_DICTIONARYITEMBASE_OSSZES orszag ON orszag.ID = c.C_ORSZAG
      AND orszag.C_TANEVID = c.C_TANEVID
      AND orszag.TOROLT = 'F'
    INNER JOIN T_ORSZAGTIPUS_OSSZES iso ON iso.ID = orszag.ID
      AND iso.C_ALTANEVID = orszag.C_TANEVID
      AND iso.TOROLT = 'F'
    WHERE c.C_GONDVISELOID = @pGondviseloId
      AND c.TOROLT = 'F'
      AND c.C_TANEVID = @pTanevId
  END
GO


