分页SQLServer数据库存储过程
select colid from sysindexkeys where @Obj_ID=id and indid in(
select indid from sysindexes where @Obj_ID=id and name in(
select name from sysobjects where xtype='PK' and parent_obj=@Obj_ID
)))
select @strfd=substring(@strfd,2,2000)
,@strjoin=substring(@strjoin,5,4000)
,@strwhere=substring(@strwhere,5,4000)
goto lbusepk
end
end
end
else
goto lbusetemp
copyright dedecms
/*--使用标识列或主键为单一字段的处理方法--*/
lbuseidentity:
exec('select top ' @Id1 @FdShow ' from ' @QueryStr
' where ' @FdName ' not in(select top '
@Id2 ' ' @FdName ' from ' @QueryStr @FdOrder
')' @FdOrder
)
return copyright dedecms
/*--表中有复合主键的处理方法--*/
lbusepk:
exec('select ' @FdShow ' from(select top ' @Id1 ' a.* from
(select top 100 percent * from ' @QueryStr @FdOrder ') a
left join (select top ' @Id2 ' ' @strfd '
from ' @QueryStr @FdOrder ') b on ' @strjoin '
where ' @strwhere ') a'
)
return 本文来自织梦
/*--用临时表处理的方法--*/
lbusetemp:
select @FdName='[ID_' cast(newid() as varchar(40)) ']'
,@Id1=cast(@PageSize*(@PageCurrent-1) as varchar(20))
,@Id2=cast(@PageSize*@PageCurrent-1 as varchar(20))
内容来自dedecms
exec('select ' @FdName '=identity(int,0,1),' @FdShow '
into #tb from' @QueryStr @FdOrder '
select ' @FdShow ' from #tb where ' @FdName ' between '
@Id1 ' and ' @Id2
) 内容来自dedecms
GO copyright dedecms
asp">存储过程asp?tags=分页">分页asp?tags=数据库">数据库
文章评论
共有位Admini5网友发表了评论 查看完整内容