儲存過程的分頁!!

2021-04-17 07:53:50 字數 1803 閱讀 6594

create proc up_gettopiclist

@a_strforumid varchar(50) ,

@a_intpageno int  ,

@a_intpagesize int

as/*定義區域性變數*/

declare @intbeginid         int

declare @intendid           int

declare @introotrecordcount int

declare @intpagecount       int

declare @introwcount        int

/*關閉計數*/

set nocount on

/*求總共根貼數*/

select @introotrecordcount = count(*) from bbs_topic where fatherid=0 and forumid=@a_strforumid

if (@introotrecordcount = 0)    --如果沒有貼子,則返回零

return 0

/*判斷頁數是否正確*/

if (@a_intpageno - 1) * @a_intpagesize > @introotrecordcount

return (-1)

/*求開始rootid*/

set @introwcount = (@a_intpageno - 1) * @a_intpagesize + 1

/*限制條數*/

set rowcount @introwcount

select @intbeginid = rootid from bbs_topic where fatherid=0 and forumid=@a_strforumid

order by tid desc

/*結束rootid*/

set @introwcount = @a_intpageno * @a_intpagesize

/*限制條數*/

set rowcount @introwcount

select @intendid = rootid from bbs_topic where fatherid=0 and forumid=@a_strforumid

order by tid desc

/*恢復系統變數*/

set rowcount 0

set nocount off   

select a.tid , a.layer , a.forumid , a.subject , a.faceid , a.hits , a.posttime , a.userid , a.fatherid , a.rootid ,

'bytes' = datalength(a.content) , b.loginname  , b.email  , b.homepage , b.signature , b.point

from bbs_topic as a join bbs_user as b on a.userid = b.uid

where forumid=@a_strforumid and a.rootid between @intendid and @intbeginid

order by a.rootid desc , a.ordernum desc

return(@@rowcount)

--select @@rowcount

go    

seover="window.status='正文--

儲存過程的

分頁!!';return true">

分頁儲存過程 分頁儲存過程

分頁儲存過程 alter proc dbo p pageshow pagesize int,每頁大小 currentpage int out,當前頁 housename nvarchar 50 房產名稱 totalcount int out,總記錄數 totalpage int out 總頁數 as...

分頁的儲存過程

alter procedure sql conn sort tblname varchar 255 表名 strgetfields varchar 1000 需要返回的列 fldname varchar 255 排序的欄位名 pagesize int 頁尺寸 pageindex int 頁碼 doc...

分頁的儲存過程

create proc proc pager tblname varchar 20 表名 pagesize int 10,每頁資料行數 pagenum int 1,頁數 sortname varchar 20 排序列名 asdeclare count int set count pagesize p...