Morning Andy,
Great question! My understanding when using ROW_NUMBER for windowed results (limit/offset) is that it is not needed since the "OVER (ORDER BY..." will order the inner results and the select around it does not need it. However, if this is not the case and the extra "ORDER BY [__rnt].[__rn]" is needed, then I would be open to such a patch. Can you investigate this more and open a ticket with information and possibly a link or content back to this thread?
Lastly, one thing that throws up newcomers to SQL Server is that unlike other DBs, it does not like ambiguous results. This is why we have Arel helper methods like #rowtable_orders that find your specified order or use the tables primary key or first column. That code received a few patches up to the 3.2 work. So it could be possible that your issue is related to (a) not specifying an explicit order and (b) the #rowtable_order picking a column that would lead to ambiguous results.
- HTH,
Ken