title: SQL How to loop through a table and merge result?
body: <p>I am trying to do something like this:</p>
  <pre><code>while @nrOfAuthlevels &gt;= @myAuthLevel
  begin
      set @myAuthLevel = @myAuthLevel + 1 
      SELECT      Role.name, Role.authorityLevel
      FROM        [dbo].[Role]
      ORDER BY Role.authorityLevel
  end
  </code></pre>
  <p>The result of this stored procedure shall be a table with all Role.authorityLevel below my own. But this generates several tables.</p>