create PRoc usp_getPageData @totalCount int output,--總頁數 @pageIndex int ,--當前面索引 @pageCount int--每一頁顯示的記錄數as--獲取擁有行號的結果集--select ROW_NUMBER() over(order by sid) , * from dbo.vw_GetStockInfo--從擁有行號的結果集中再進行查詢,使用行號進行條件的判斷:獲取結果集select * from (select ROW_NUMBER() over(order by sid) id , * from dbo.vw_GetStockInfo) tempwhere id between (@pageIndex-1)*@pageCount+1 and @pageIndex*@pageCount--獲取總頁數set @totalCount=CEILING((select count(*) from vw_GetStockInfo) *1.0/@pageCount)go
新聞熱點
疑難解答