日期:2014-05-17 浏览次数:20520 次
--Drop PROCEDURE [dbo].[FenYe]
CREATE PROCEDURE [dbo].[FenYe]
@curPage int, --当前页数
@pageSize int, -- 每页显示的数量
@th varchar(200) = '', --查询,图号
@mc varchar(200) = '', --查询,名称
@tm varchar(200) = '', --查询,条码
@gysdm varchar(200)='' --查询,供应商代码
AS
Begin
Declare @before int,@sql nvarchar(1000)
Set @before=(@curpage-1)*@pageSize
Set @sql='select top '+cast(@pageSize as varchar(10))+' th,bh,mc,wlbh,tx,dw,nx,xfdw_dm,xfdw_mc,no_bh,rq,bz,glry,bgy From tm_wlbh
where id not in (Select top '+cast(@before as varchar(10))+' id from tm_wlbh where (th like ''%''+@th+''%'' or bh like ''%''+@th+''%'') and mc like ''%''+@mc+''%'' and wlbh like ''%''+@tm+''%'' and xfdw_dm like ''%''+@gysdm+''%'' order by id)'
Exec (@sql)
End
--exec FenYe 1,30,'','','',''
调用时报错:消息 137,级别 15,状态 2,第 2 行
必须声明标量变量 "@th"。
--Drop PROCEDURE [dbo].[FenYe]
CREATE PROCEDURE [dbo].[FenYe]
@curPage INT , --当前页数
@pageSize INT , -- 每页显示的数量
@th VARCHAR(200) = '' , --查询,图号
@mc VARCHAR(200) = '' , --查询,名称
@tm VARCHAR(200) = '' , --查询,条码
@gysdm VARCHAR(200) = '' --查询,供应商代码
AS
BEGIN
DECLARE @before INT ,
@sql NVARCHAR(1000)
SET @before = ( @curpage - 1 ) * @pageSize
SET @sql = 'select top ' + CAST(@pageSize AS VARCHAR(10))
+ ' th,bh,mc,wlbh,tx,dw,nx,xfdw_dm,xfdw_mc,no_bh,rq,bz,glry,bgy From tm_wlbh
where id not in (Select top ' + CAST(@before AS VARCHAR(10))
+ ' id from tm_wlbh where (th like ''%''+'+@th+'+''%'' or bh like ''%''+'+@th+'+''%'') and mc like ''%''+'+@mc+'+''%'' and wlbh like ''%''+'+@tm+'+''%'' and xfdw_dm like ''%''+'+@gysdm+'+''%'' order by id)'
EXEC (@sql)
END
--exec FenYe 1,30,'','','',''