@pageSize int,
@pageNumber int
AS
Declare @rowStart int
Declare @rowEnd int
if @pageNumber > 0
Begin
SET @pageNumber = @pageNumber -1
SET @rowStart = @pageSize * @pageNumber + 1;
SET @rowEnd = @rowStart + @pageSize - 1 ;
With Temp AS --用with申明一张Temp表,保存查询结果
( SELECT *, --[*]可以指定具体的哪些要查询的列名
ROW_NUMBER() OVER (order by employee) as rowNumber --[ProductID]是用来排序的字段,[rowNumber]指定一个行号,以方便分页
FROM from employee_external_right ) --[Product]指定在查询的表名
select *
from Temp
Where rowNumber >= @rowStart and rowNumber <= @rowEnd
END |