@StartIndex為當前頁起始序號,@EndIndex為當前頁結束記錄序號,可以直接作為參數輸入,也可以通過輸入PageSize和PageIndex計算得出
復制代碼 代碼如下:
select * from
(
select *,row_number() over(order by OrderColumn) as orderindex from TableName
) as a
where a.orderindex between @StartIndex and @EndIndex