CREATE PROCEDURE dbo.PPOK_HousePage
(@int_pagenow int=0,
@int_pagesize int=0,
@str_SQLWhere varchar(222),
@int_recordcount int=0 output)AS
set nocount ondeclare @int_allid int
declare @int_beginid int,@int_endid int
declare @int_pagebegin int, @int_pageend int   select @int_allid=count(sID) from PPOK_House
   select @int_recordcount=@int_allid   declare cro_fastread cursor scroll
   for
     select sID from PPOK_House order by sID desc   open cro_fastread
   select @int_beginid=(@int_pagenow-1)*@int_pagesize+1
   select @int_endid = @int_beginid+@int_pagesize-1   fetch absolute  @int_beginid from cro_fastread into @int_pagebegin
   if @int_endid>@int_allid
       fetch last from cro_fastread into @int_pageend
   else
       fetch absolute @int_endid from cro_fastread into @int_pageend   select * from PPOK_House where sID between @int_pageend and @int_pagebegin
order by sID desc   close cro_fastread
   deallocate cro_fastread   return
GO====================================================我想在最后一句添上 @str_SQLWhere 变量该如何做呢?谢谢了。
即这句:   select * from PPOK_House where sID between @int_pageend and @int_pagebegin
order by sID desc

解决方案 »

  1.   

    select * from PPOK_House where sID between @int_pageend and @int_pagebegin 
    and @str_SQLWhere   
    order by sID desc
      

  2.   

    分页?用得着也存储过程吗。不明白@str_SQLWhere 是有想做什么用的。
      

  3.   

    select * from PPOK_House where sID between @int_pageend and @int_pagebegin
    and @str_SQLWhere
    order by sID desc====================sql 提示语法错误 在 and 附近
      

  4.   

    @str_SQLWhere 是条件。就是外部变量。是定义好的sql条件语句如: "and a=1 and b=2 "之类的。目的是加入查询条件
      

  5.   

    declare @sql nvarchar(5000)
    set @sql='select * from PPOK_House where sID between '+ltrim(@int_pageend)+' and '+ltrim(@int_pagebegin)+@str_SQLWhere +' order by sID desc'
    exec sq_executesql @sql
      

  6.   

    Microsoft OLE DB Provider for SQL Server 错误 '80040e14' 未能找到存储过程 'sq_executesql'。 
      

  7.   

    chuifengde(树上的鸟儿) 谢谢可以了。但我统计总数的也得改过来,即这句也得加上条件:   select @int_allid=count(sID) from PPOK_House如何改呀?最后一步了:)