这篇文章主要为大家详细介绍了SQL Server四种分页的简单示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编两巴掌来看看吧!
select * from (
select *, ROW_NUMBER() OVER(Order by ArtistId ) AS RowId from ArtistModels
) as b
where RowId between 10 and 20
---where RowId BETWEEN 当前页数-1*条数 and 页数*条数---
执行结果是:【图片暂缺】
select * from ArtistModels order by ArtistId offset 4 rows fetch next 5 rows only
--order by ArtistId offset 页数 rows fetch next 条数 rows only ----
执行结果是:【图片暂缺】
select top 3 * from ArtistModels
where ArtistId not in (select top 15 ArtistId from ArtistModels)
------where Id not in (select top 条数*页数 ArtistId from ArtistModels)
执行结果:【图片暂缺】
CREATE procedure page_Demo
@tablename varchar(20),
@pageSize int,
@page int
AS
declare @newspage int,
@res varchar(100)
begin
set @newspage=@pageSize*(@page - 1)
set @res='select * from ' +@tablename+ ' order by ArtistId offset '+CAST(@newspage as varchar(10)) +' rows fetch next '+ CAST(@pageSize as varchar(10)) +' rows only'
exec(@res)
end
EXEC page_Demo @tablename='ArtistModels',@pageSize=3,@page=5
执行结果:【图片暂缺】
本文来自:http://www.q1010.com/179/9107-0.html
注:关于SQL Server四种分页的简单示例的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:SQL SERVER
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。