SQL 2000 (一个简单并且很重要的问题)分页
来源:百度知道 编辑:UC知道 时间:2024/06/13 15:00:59
--存储过程--
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
希望大家帮我修改一下
错误:服务器: 消息 170,级别 15,状态 1,过程 pro_WareInfo,行 19
第 19 行: '@ipage' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,过程 pro_WareInfo,行 20
第 20 行: '@ipage' 附近有语法错误。
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
希望大家帮我修改一下
错误:服务器: 消息 170,级别 15,状态 1,过程 pro_WareInfo,行 19
第 19 行: '@ipage' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,过程 pro_WareInfo,行 20
第 20 行: '@ipage' 附近有语法错误。
CREATE PROCEDURE pagination3
@tblName varchar(255), -- 表名
@strGetFields varchar(1000) = '*', -- 需要返回的列
@fldName varchar(255)='', -- 排序的字段名
@PageSize int = 10, -- 页尺寸
@PageIndex int = 1, -- 页码
@doCount bit = 0, -- 返回记录总数, 非 0 值则返回
@OrderType bit = 0, -- 设置排序类型, 非 0 值则降序
@strWhere varchar(1500) = '' -- 查询条件 (注意: 不要加 where)
AS
declare @strSQL varchar(5000) -- 主语句
declare @strTmp varchar(110) -- 临时变量
declare @strOrder varchar(400) -- 排序类型
if @doCount != 0
begin
if @strWhere !=''
set @strSQL = "select count(*) as Total from [" + @tblName + "] where "+@strWhere
else
set @strSQL = "select count(*) as Total from [" + @tblName + "]"