DROP PROCEDURE  IF EXISTS uspGetFelhasznaloEmailCimEugyintezes 
GO

CREATE PROCEDURE uspGetFelhasznaloEmailCimEugyintezes
  @pId INT
AS
BEGIN
  SET NOCOUNT ON;

  SELECT e.C_EMAILCIM AS EmailCim
    ,IIF(e.C_ALAPERTELMEZETT = 'T', 1, 0) AS Alapertelmezett
    ,e.C_GUID AS Guid
  FROM T_FELHASZNALO_OSSZES fh
  INNER JOIN T_EMAIL_OSSZES e ON fh.ID = e.C_FELHASZNALOID
    AND e.C_GONDVISELOID IS NULL
    AND e.TOROLT = 'F'
    AND e.C_ISHIBASANMEGADVA = 'F'
  WHERE fh.ID = @pId
    AND fh.TOROLT = 'F'
  ORDER BY Alapertelmezett DESC
END
GO


