Home > Database > Mysql Tutorial > sqlserver使用窗口函数实现分页

sqlserver使用窗口函数实现分页

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:46:03
Original
945 people have browsed it

欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入 sqlserver使用窗口函数实现分页 ALTER PROC [dbo].[usp_GetStuPage] @pageIndex INT =1,--当前页码 @pageSize INT =10,--页容量 @pageCount int OUTPUT--输出总页数 AS BEGIN SELECT @pageCount=CE

欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入

  sqlserver使用窗口函数实现分页

  ALTER PROC [dbo].[usp_GetStuPage]

  @pageIndex INT =1,--当前页码

  @pageSize INT =10,--页容量

  @pageCount int OUTPUT--输出总页数

  AS

  BEGIN

  SELECT @pageCount=CEILING((COUNT(id)*1.0)/@pageSize) FROM StudentsInfo

  SELECT * FROM (

  SELECT *,ROW_NUMBER() OVER(ORDER BY id) AS rownum FROM StudentsInfo

  )AS t  WHERE t.rownum BETWEEN (@pageIndex-1)*@pageSize+1 AND @pageIndex*@pageSize

  END

sqlserver使用窗口函数实现分页

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template