title: Assign the results of a stored procedure into a variable in another stored procedure
body: <p>The title of this question is a bit misleading, but I couldn't summarize this very well.</p>
  
  <p>I have two stored procedures. The first stored procedure (<code>s_proc1</code>)  calls a second stored procedure (<code>s_proc2</code>). I want to assign the value returned from <code>s_proc2</code> to a variable in <code>s_proc1</code>. Currently, I'm calling <code>s_proc2</code> (inside <code>s_proc1</code>) in this manner:</p>
  
  <pre><code>EXEC s_proc2 @SiteID, @count = @PagingCount OUTPUT
  </code></pre>
  
  <p><code>s_proc2</code> contains a dynamic query statement (for reasons I will not outline here).</p>
  
  <pre><code>CREATE dbo.s_proc2
  (
      @siteID int,
      @count int OUTPUT
  )
  
  AS
  
  DECLARE @sSQL nvarchar(100)
  DECLARE @xCount int
  
  SELECT @sSQL = 'SELECT COUNT(ID) FROM Authors'
  
  EXEC sp_ExecuteSQL @sSQL, N'@xCount int output', @xCount output
  SET @count = @xCount
  RETURN @count
  </code></pre>
  
  <p>Will this result in <code>@PagingCount</code> having the value of <code>@count</code>? I ask because the result I am getting from <code>s_proc1</code> is wonky. In fact, what I do get is two results. The first being <code>@count</code>, then the result of <code>s_proc1</code> (which is incorrect). So, it makes me wonder if <code>@PagingCount</code> isn't being set properly.</p>
  
  <p>Thank you.</p>