--建立人:zengfanlong10:51:15
--說明:根據公司簡寫**獲取當前待同步的氣瓶檔案資料(分頁獲取)
alter procedure [up_gasbottles_getsyncdata_bypage]
(@companyabbrcode nvarchar(
255) = ''
, @latastrowversion_bigint bigint ,
@currentmaxrowversion_bigint bigint ,
@startpageindex int = 0
, @endpageindex int = 0
, @totalcount int output
)as begin
--(1
)、定義sql查詢
select *into #temptb
from dbo.gasbottles as gs with ( nolock )
where isnull(gasbottleno,
'') <> ''
and replace(( substring(gs.gasbottleno,
1, 5) ), '
-', '') =@companyabbrcode
and ( cast([rowversion] as bigint) >@latastrowversion_bigint
and cast([rowversion] as bigint)
<=@currentmaxrowversion_bigint
)if ( @startpageindex
<= 0
and @endpageindex
<= 0
) begin
select *from #temptb
--返回總頁數
set @totalcount = ( select count(1
) from #temptb
)
endelse
begin
--分頁獲取資料
select row_number() over ( order by getdate() ) as
'row',
*into #tempall
from #temptb
select *from #tempall
where row between @startpageindex and @endpageindex
truncate table #tempall
drop table #tempall
end--刪除歷史表
truncate table #temptb
drop table #temptb
endgo
通過儲存過程進行分頁查詢的SQL示例
建立人 zengfanlong 10 51 15 說明 根據公司簡寫 獲取當前待同步的氣瓶檔案資料 分頁獲取 alter procedure up gasbottles getsyncdata bypage companyabbrcode nvarchar 255 latastrowversion ...
通過儲存過程分頁
asp.net中實現分明功能,主要運用的是aspnetpager,再呼叫儲存過程進行分頁,該方法適合運用的範圍非常廣,不錯,set ansi nulls on set quoted identifier on goalter procedure dbo getpagerdata 表名 tbname ...
使用儲存過程進行分頁的 儲存過程
使用儲存過程進行分頁的 use blog gocreate procedure blogcontent page pagesize int,一頁多少條 pageindex int,第幾頁 pagecount int output 一共多少頁,輸出引數 asbegin declare totalrec...