title: T-SQL loop over query results
body: <p>I run a query <code>select @id=table.id from table</code> and I need to loop over the results so I can exec a store procedure for each row <code>exec stored_proc @varName=@id,@otherVarName='test'</code></p>
  
  <p>How can I do this in a T-SQL script?</p>