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 有些情况下效率低下
转成通用的分页存储过程