title: Select every nth row in SQL
body: <p>Been a while since I did some SQL, so I have been given some to look at and try to make more efficient, with a table that has millions of rows.</p>
  
  <p>And I want to select every 100,000th sequenceid (not row, so row_number() is not being used) into a tempory table, at the moment it is doing this, now granted it takes about 15 seconds, but is there a more efficient and quicker way?</p>
  
  <pre><code>declare @temp table(id int, date datetime)
  declare @loop int, @max int, @min int
  select @min = min(id) from tableA
  select @max = max(id) from tableA
  set @loop = @min + 100000
  
  while (@loop &lt; @max)
  begin
    insert into @temp
    select id, date from tableA where id = @loop
    set @loop = @loop + 100000
  end
  </code></pre>