大数据量SqlServer效率分页

转载请注明出处http://blog.csdn.net/xugangjava

SET @rowsPerPage = 10 
   

SET @pageNum = 3 
     
    With SQLPaging 
    As 
    ( 
    Select Top(@rowsPerPage * @pageNum) ROW_NUMBER() OVER (ORDER BY id) as resultNum, id 
    FROM myTable 
    ) 
    select * from SQLPaging where resultNum > ((@pageNum - 1) * @rowsPerPage)  


分页不要用where not in 有些情况下效率低下

转成通用的分页存储过程

http://blog.csdn.net/xugangjava/article/details/7164711

你可能感兴趣的:(SQL)