title: How can I return a sql select into a sql variable
body: <p>I'm trying to put the results of a <code>SELECT</code> into a variable and loop through the results to manipulate that data, all in the same stored proceedure... Here's what I have so far:</p>
  
  <pre><code>DECLARE @i int
  
  @Result = (SELECT * FROM UserImport)
  
  SET @i = 0
  WHILE @i &lt; (SELECT Count(@Result) As Count)
  BEGIN
     /* Do Stuff */
  END
  </code></pre>
  
  <p>I know I'm way off because it's saying <code>@Result</code> was not declared, but I'm not sure how to declare a variable to be able to hold the results of a <code>SELECT</code> statement.</p>
  
  <p>Can anyone tell me where i'm going wrong and how to fix it?</p>
  
  <p>Thanks,<br/>
  Matt</p>