alter procedure [dbo].[Proc_NewsList]
(
@dqid int,--城市id
@flid int,--分类id
@maximumRows int,
@startRowIndex int,
@jine varchar(50),-- zu jin
@hxid int,-- hu xing
@mianji varchar(50),--mian ji
@bqid int,-- biao qian
@tbname varchar(20)-- biao ming
)
as
declare @strsql varchar(800)
declare @strwhere varchar(200)
set @strwhere=''
set @strsql='select id,title,content,jytype1,jytype2,jytype3,age,jine,photo1,photo2,photo3,addtime,diqu_title,fenlei_title,deltype,diqu_id,mdiqu_id,pdiqu_id,fileurl,biaoqian,pfenlei_id,fenlei_id,sfenlei_id,photo4,bkzd3,addtime1,emilimg from (select ROW_NUMBER()Over(order by addtime desc) as rowId,* from '+@tbname
if @jine <> '' and @jine is not null
set @strwhere = @strwhere + ' and ('+@jine+') '
if @hxid <> 0
set @strwhere = @strwhere + ' and (jytype3 = '+str(@hxid)+')'
if @mianji <> '' and @mianji is not null
set @strwhere = @strwhere + ' and ('+@mianji+')'
if @bqid <> 0
set @strwhere = @strwhere + ' and (bqbg = ' + str(@bqid)+')'
set @strwhere=substring(@strwhere,5,len(@strwhere))
set @strsql=@strsql+' where '+@strwhere
set @strsql=@strsql+') as mytable where rowId between '+str(@startRowIndex)+' and '+str(@startRowIndex+@maximumRows)
exec(@strsql)
sql 分页查询
最新推荐文章于 2021-09-13 17:48:07 发布