Maison > base de données > tutoriel mysql > sqlserver使用窗口函数实现分页

sqlserver使用窗口函数实现分页

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Libérer: 2016-06-07 15:46:03
original
927 Les gens l'ont consulté

欢迎进入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使用窗口函数实现分页

Étiquettes associées:
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal