title: Return one OUTPUT result from MERGE query
body: <p>I have a merge query which updates or inserts if no records found. In my results, I have a problem when the record does not exist and it get inserted. The query returns BOTH 'Updated' (as empty) and 'Inserted' (with the proper value). </p>
  
  <p>Any ideas how to avoid return the empty 'Updated' when there are no updates?</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[spInsOrUpdApplicant]
      -- Add the parameters for the stored procedure here
      @Name nvarchar(50),
      @Surname nvarchar(50),
      @Position nvarchar(50),
      @NationalID int,
      @ApplicantID int
  
  AS
  BEGIN
      SET NOCOUNT ON;
  -- Update the row if it exists.    
      UPDATE tbApplicant
      SET Name = @Name, Surname = @Surname, Position = @Position, NationalID = @NationalID
  
          OUTPUT INSERTED.ApplicantID AS 'Result'
  
      WHERE ApplicantID = @ApplicantID;
  
  -- Insert the row if the UPDATE statement failed.   
      IF (@@ROWCOUNT = 0 )
      BEGIN
          INSERT INTO tbApplicant (Name, Surname, Position, NationalID)
          OUTPUT INSERTED.ApplicantID AS 'Result'
          VALUES (@Name, @Surname, @Position, @NationalID)
      END
  
  END;
  </code></pre>