title: Select and assign to variable in one statement?
body: <p>I'd like to display the results of a query, and I'd like to capture a column's value at the same time. The <code>FROM</code> and <code>WHERE</code> are the same in both queries. Can I do both in one query, or is it easier/better to just do the query twice, like this?</p>
  
  <pre><code>DECLARE @fooId INT
  
  SET @fooId = (SELECT FooId FROM Bar WHERE SnuhId = 5)
  
  SELECT * FROM Bar WHERE SnuhId = 5
  </code></pre>