title: T-SQL get SELECTed value of stored procedure
body: <p>In T-SQL, this is allowed:</p>
  
  <pre><code>DECLARE @SelectedValue int
  SELECT @SelectedValue = MyIntField FROM MyTable WHERE MyPrimaryKeyField = 1
  </code></pre>
  
  <p>So, it's possible to get the value of a SELECT and stuff it in a variable (provided it's scalar, obviously).</p>
  
  <p>If I put the same select logic in a stored procedure:</p>
  
  <pre><code>CREATE PROCEDURE GetMyInt
  AS
  SELECT MyIntField FROM MyTable WHERE MyPrimaryKeyField = 1
  </code></pre>
  
  <p>Can I get the output of this stored procedure and stuff it in a variable?</p>
  
  <p>Something like:</p>
  
  <pre><code>DECLARE @SelectedValue int
  SELECT @SelectedValue = EXEC GetMyInt
  </code></pre>
  
  <p>(I know the syntax above is not allowed because I tried it!)</p>