title: How to use a value from one stored procedure in another?
body: <p>I have the following statement in a stored procedure:</p>
  <pre><code>DECLARE @Count INT
  EXEC @Count = GetItemCount 123
  SELECT @Count
  </code></pre>
  <p>Which calls another stored procedure with the following statement inside:</p>
  <pre><code>SELECT COUNT(Item) 
  FROM tblItem 
  WHERE ID = @ID
  </code></pre>
  <p>However when I test the call the <code>EXEC</code> outputs the value correctly but it
  is not assigned to the <code>@Count</code> parameter correctly.</p>
  <p>I've seen examples or stored procedures used like this, including here but none had a parameter and a return value used (that I could find).</p>
  <p>The <code>ID</code> parameter is passed into the second statement which returns a count value used by the first stored procedure - all the info I have read seems to indicate this should work - but it doesn't the @Count value is always zero, even when the <code>GetItemCount</code> returns always the correct value.</p>
  <p>This is in Microsoft SQL Server 2008 if that helps.</p>