title: Stored procedure inside cursor not updating local variable from output parameter
body: <p>I'm having trouble with the output parameter of a stored procedure that's being executed inside the while loop of a cursor. </p>
  
  <pre><code>DECLARE @p_in int
  DECLARE @p_out char
  
  OPEN crs_clientId
  
  FETCH NEXT FROM crs_clientId INTO @p_in
  
  WHILE @@FETCH_STATUS = 0
  BEGIN
      PRINT @p_in
  
      EXEC dbo.usp_get_letter_for_number
               @in = @p_in, @out = @p_out OUTPUT;
  
      PRINT @p_out
  
      FETCH NEXT FROM crs_clientId INTO @p_in
  END
  
  CLOSE crs_clientId
  DEALLOCATE crs_clientId
  </code></pre>
  
  <p>If I run this stored procedure independently, I get:</p>
  
  <pre><code>1
  A
  2
  B
  3
  C
  </code></pre>
  
  <p>However, running it within the the cursor I get:</p>
  
  <pre><code>1
  A
  2
  A
  3
  A
  </code></pre>
  
  <p>What am I missing? Why is the stored procedure only updating <code>@p_out</code> on the first pass?</p>