if (exists (select * from sys.objects where name = 'f_newspage'))
drop proc f_newspage
go
CREATE PROCEDURE [f_newspage]
(
@sqlstr nvarchar(200),
@pageIndex int,
@pageSize int
)
as
if @sqlstr is not null
begin
select * from
(select *,row_number() over(order by news_id asc) as newsid from t_news where @sqlstr = SUBSTRING(@sqlstr,5,4000)) as temp
where newsid between @pageSize*(@pageIndex-1)+1 and @pageSize*@pageIndex
return
end
if @sqlstr is null
begin
select * from
(select *,row_number() over(order by news_id asc) as newsid from t_news) as temp
where newsid between @pageSize*(@pageIndex-1)+1 and @pageSize*@pageIndex
return
end