goohugo / myblog

该仓库为个人博客,请不要提 issue ,该仓库后端参考了 @yihong0618 的 gitblog 项目,前端参考了@LoeiFy 的 Mirror 项目,感谢!
MIT License
2 stars 1 forks source link

SQL2012的新分页方法 #16

Open goohugo opened 1 year ago

goohugo commented 1 year ago
DECLARE @PageNumber INT = 6
DECLARE @RowsCountPerPage INT = 10

SELECT  BusinessEntityID ,
        FirstName ,
        LastName
FROM    Person.Person
ORDER BY BusinessEntityID
        OFFSET ( @PageNumber - 1 ) * @RowsCountPerPage ROWS
 FETCH NEXT @RowsCountPerPage ROWS ONLY