SQL2005中利用存储过程分页
2010-12-08 21:25
134 查看
--进行top查询时 ,参数需要带上()
declare @page int,@pagesize int
set @page=2
select top (@page) * from usertb
--分页
select top 2 * from usertb where userid not in
(select top 2 userid from usertb order by username) order by username
--分页语句块
declare @pageSize int--页数大小
declare @pageIndex int--页码
set @pageSize = 2
set @pageIndex =1
select top ( @pagesize ) * from usertb
where userid not in(
select top (@pageSize*(@pageIndex-1)) userid
from usertb order by username )
order by username
--获得表的总数据量
create proc proc_countres(@count int output)
as
begin
select @count=count(*) from usertb
end
--根据用户指定的页码获得数据集
create proc proc_getres(@pageSize int,@pageIndex int)
as
begin
select top ( @pagesize ) * from usertb
where userid not in(
select top (@pageSize*(@pageIndex-1)) userid
from usertb order by username )
order by username
end
--获取指定页的结果集
exec proc_getres @pageSize=2,@pageIndex=1
--获得总的数据量
declare @count int
exec proc_countres @count output
print @count
declare @page int,@pagesize int
set @page=2
select top (@page) * from usertb
--分页
select top 2 * from usertb where userid not in
(select top 2 userid from usertb order by username) order by username
--分页语句块
declare @pageSize int--页数大小
declare @pageIndex int--页码
set @pageSize = 2
set @pageIndex =1
select top ( @pagesize ) * from usertb
where userid not in(
select top (@pageSize*(@pageIndex-1)) userid
from usertb order by username )
order by username
--获得表的总数据量
create proc proc_countres(@count int output)
as
begin
select @count=count(*) from usertb
end
--根据用户指定的页码获得数据集
create proc proc_getres(@pageSize int,@pageIndex int)
as
begin
select top ( @pagesize ) * from usertb
where userid not in(
select top (@pageSize*(@pageIndex-1)) userid
from usertb order by username )
order by username
end
--获取指定页的结果集
exec proc_getres @pageSize=2,@pageIndex=1
--获得总的数据量
declare @count int
exec proc_countres @count output
print @count
相关文章推荐
- 利用SQL2005的row_number()重新写了个自定义分页存储过程
- 利用存储过程进行高效分页的例子
- asp.net结合aspnetpager使用SQL2005的存储过程分页(转)
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- [转]一个利用Sql Server 20005的 ROW_NUMBER Function 的分页存储过程.
- 利用SQL未公开的存储过程实现分页
- SQL Server中利用存储过程来高性能地进行分页
- 利用SqlServer内部存储过程实现快速方便的分页
- SQL2005的分页存储过程,支持多表多关联,亲测高效绝对可用
- 利用存储过程进行高效分页的例子
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- 利用存储过程实现数据分页
- 最热网友收藏:利用SqlServer内部存储过程实现快速方便的分页(2007年第7周)
- 修改后的SQL分页存储过程,利用2分法,支持排序
- SQL Server中利用存储过程来高性能地进行分页
- 利用SQL未公开的存储过程实现分页
- 利用存储过程实现分页 ,并且多条件查询
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页
- ASP.NET中利用DataGrid的自定义分页功能和存储过程结合实现高效分页