title: SQL - Save results from stored procedure to a variable
body: <p>I have a stored procedure that I cannot change. And it returns a select value (integer). </p>
  
  <p>It insert some values and return the new id - the last line of the stored procedure:</p>
  
  <pre><code>SELECT @newID
  </code></pre>
  
  <p>I am using the new ID but I don't want to display that value when I run the stored procedure.</p>
  
  <p>So I use the following:</p>
  
  <pre><code>DECLARE @test INT 
  EXEC @test = Pr_My_Procedure 'NewGroupName'
  SELECT @test
  </code></pre>
  
  <p>This executes successfully, but my variable @test is always = 0 when the actual value created and return for the stored procedure is an actual id number.</p>
  
  <p>Why is my variable is not being assigned?</p>
  
  <p>I have a work around (which is not really what I wanted but it works:</p>
  
  <pre><code>1    DECLARE @NewGroupID INT    
  2    EXEC Pr_My_Procedure 'NewGroupName'
  3    SET @NewGroupID = (SELECT GroupID FROM DB..Groups WHERE GroupName = 'NewGroupName')
  </code></pre>
  
  <p>This works, but when running the stored procedure, I still get the GroupID generated being return on the results (line 2). I don't want to see that.  </p>
  
  <p>Is it possible to NOT return that select result from the procedure? </p>
  
  <p>Thanks all for any advise!</p>