webdiyer的分页存储过程 参数不会写了
CREATE procedure NewhouseGetSearchResult
(@area NVarChar(10),
@key NVarChar(20),
@pagesize int,
@pageindex int,
@docount bit)
as
declare @strSQL nvarchar (1000)
select @strSQL= ' '
if (@key <> '0 ')
SELECT @key =REPLACE(@key,char(39), ' ')
SELECT @key = ' ' '% '+ @key + '% ' ' '
select @strSQL= 'and name like '+ @key + ' '
if (@area <> '0 ')
select @strSQL= 'and area = " '+@area+ ' " '
print @strSQL
set nocount on
if(@docount=1)
select count(id) from loupan where 1=1 @strSQL
else
begin
declare @indextable table(id int identity(1,1),nid int)
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(nid) select id from loupan where 1=1 @strSQL order by id desc
select O.id,O.[name],O.dizhi,O.price1,O.biaozhun,O.areatype,O.jingguantu,O.tel,send_time,0 from loupan O,@indextable t where O.id=t.nid
and t.id> @PageLowerBound and t.id <=@PageUpperBound order by t.id
end
set nocount off
GO
select count(id) from loupan where 1=1 @strSQL
这句该怎么写? @strsql (参数)
[解决办法]
上面的不对
declare @t nvarchar(1500)
select @t= 'select @a=count(id) from loupan where 1=1 '+@strSQL
exec sp_executesql @t,N '@a int output ',@a output
这样可以