ALTER procedure [dbo].[selTestTable]
@PageIndex int,
@PageSize int
as
Declare @rowcount numeric
Declare @intStart numeric
set nocount on
set @intStart=(@PageIndex-1)*@PageSize+1
if @intStart=1
SELECT @rowcount=count(ID) from TestTable where FirstName like '%aa%'
else
set @rowcount=0
;
WITH PartsCTE AS(Select ROW_NUMBER() OVER(order by ID) as row,
*
From TestTable where FirstName like '%aa%'
)
Select *
From PartsCTE A
where row between @intStart and @intStart+@PageSize-1
return @rowcount
set nocount off
@PageIndex int,
@PageSize int
as
Declare @rowcount numeric
Declare @intStart numeric
set nocount on
set @intStart=(@PageIndex-1)*@PageSize+1
if @intStart=1
SELECT @rowcount=count(ID) from TestTable where FirstName like '%aa%'
else
set @rowcount=0
;
WITH PartsCTE AS(Select ROW_NUMBER() OVER(order by ID) as row,
*
From TestTable where FirstName like '%aa%'
)
Select *
From PartsCTE A
where row between @intStart and @intStart+@PageSize-1
return @rowcount
set nocount off
--类似:
select *
from
(select row_number() over(order by isbn) as RowNum, * from tb_Bookinfo) t
where RowNum between 10 and 20