sql分页

declare @currentPageIndex int
set @currentPageIndex=3
select top 5 * from (select row_number() over(order by getdate() desc) as rownumber,* from test) as temp_table
where rownumber>5*(@currentPageIndex-1)

 

创建大量数据测试

create table test
( id int identity(1,1),
data int null
)

begin tran
declare @index int set @index=0
while(@index <100000)
begin
insert into test(data) values(FLOOR(RAND(abs(checksum(newid())))*1000))
set @index=@index+1
end
commit

你可能感兴趣的:(sql分页)