What is the best way to paginate results in SQL Server

前端 未结 19 2474
我寻月下人不归
我寻月下人不归 2020-11-22 01:36

What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?

19条回答
  •  醉话见心
    2020-11-22 02:08

    There is a good overview of different paging techniques at http://www.codeproject.com/KB/aspnet/PagingLarge.aspx

    I've used ROWCOUNT method quite often mostly with SQL Server 2000 (will work with 2005 & 2008 too, just measure performance compared to ROW_NUMBER), it's lightning fast, but you need to make sure that the sorted column(s) have (mostly) unique values.

提交回复
热议问题