sqlserver使用窗口函數(shù)實(shí)現(xiàn)分頁(yè)
ALTER PROC [dbo].[usp_GetStuPage]
@pageIndex INT =1,--當(dāng)前頁(yè)碼
@pageSize INT =10,--頁(yè)容量
@pageCount int OUTPUT--輸出總頁(yè)數(shù)
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
alter table mytable drop index mdl_tag_use_ix;//mdl_tag_use_ix是上表查出的索引名,key_name
更多信息請(qǐng)查看IT技術(shù)專欄