title: SQL Server - Pagination Without Order By Clause
body: <p>My situation is that a SQL statement which is not predictable, is given to the program and I need to do pagination on top of it. The final SQL statement would be similar to the following one:</p>
  
  <pre><code>SELECT * FROM (*Given SQL Statement*) b 
  OFFSET 0 ROWS FETCH NEXT 50 ROWS ONLY;
  </code></pre>
  
  <p>The problem here is that the <code>*Given SQL Statement*</code> is unpredictable. It may or may not contain order by clause. I am not able to change the query result of this SQL Statement and I need to do pagination on it.</p>
  
  <p>I searched for solution on the Internet, but all of them suggested to use an arbitrary column, like primary key, in order by clause. But it will change the original order.</p>