读书人

MS SQL 的分页存储过程(高手帮帮)解

发布时间: 2012-02-27 10:00:22 作者: rapoo

MS SQL 的分页存储过程(高手帮帮)
这是我的代码希望各位高手给我该一下
我不要你们的代码
非常感谢


--存储过程--

if exists(select * from sysobjects where name= 'pro_WareInfo ')
drop procedure pro_WareInfo
go
create procedure pro_WareInfo
@allpage int output, --总页数
@ipage int, --每页显示的条数
@page int --当前页数
as
declare @countipage int --总条数

select @countipage=count(*) from WareInfo

if(@countipage % @ipage=0)
begin
select @allpage=@countipage/@ipage
end
else
begin
select @allpage=@countipage/@ipage+1
end

--问题就是这一句话---
select top @ipage * from WareInfo where WareName not in(
select top @ipage*(@page-1) WareName from WareInfo order by WareName desc)order by WareName desc
--我把变量换成具体的值就没问题----
go

[解决办法]
SQL Server 2000 通用版TOP翻页

http://feb-.blog.163.com/blog/static/165778920071141459904/

在里面底部还链接了一个 SQL Server 2005 通用版翻页存储过程

读书人网 >Web开发

热点推荐