How to use OFFSET and Fetch without Order by in SQL Server

后端 未结 5 1016
我寻月下人不归
我寻月下人不归 2021-02-07 13:35

I want use OFFSET and Fetch in my SQL server 2012 query.But without any order by.I can not use order by.Because my sort order will be lost. How can I use OFFSET and Fetch withou

5条回答
  •  情深已故
    2021-02-07 13:56

    There is an even simpler way of providing a dummy ORDER BY clause:

    select * from @TempTable ORDER BY(SELECT NULL) OFFSET 20 ROWS FETCH NEXT 50 ROWS ONLY
    

提交回复
热议问题