欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

sql server實(shí)現(xiàn)分頁(yè)的方法實(shí)例分析

 更新時(shí)間:2017年03月13日 11:35:13   作者:繼續(xù)去踢波  
這篇文章主要介紹了sql server實(shí)現(xiàn)分頁(yè)的方法,結(jié)合實(shí)例形式總結(jié)分析了SQL Server實(shí)現(xiàn)分頁(yè)功能的常用sql語句,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了sql server實(shí)現(xiàn)分頁(yè)的方法。分享給大家供大家參考,具體如下:

declare @index int,@num int
set @index = 1--當(dāng)前頁(yè)
set @num = 2--單頁(yè)包含的行數(shù)
--分頁(yè)1
select top (@num) *
from ppohd
where doccode not in
(
  select top (@num * (@index -1)) doccode
  from ppohd
  order by doccode
)
order by doccode
--分頁(yè)2
select top (@num) *
from ppohd
where doccode >=
(
  select max(doccode)
  from
  (
    select top (@num * (@index - 1) + 1) doccode
    from ppohd
    order by doccode
  ) as tb
)
--分頁(yè)3
select top (@num) *
from
(
  select ppohd.doccode as 'mydoccode',row_number() over (order by doccode) as sno,*
  from ppohd
) as tb
where tb.sno >= @num * (@index - 1) + 1
--分頁(yè)4
select *
from
(
  select ppohd.doccode as 'mydoccode', row_number() over(order by doccode) as sno,*
  from ppohd
) as tb
where tb.sno between (@num * (@index - 1) + 1) and (@num * @index)

更多關(guān)于SQL Server相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《SQL Server分頁(yè)技術(shù)總結(jié)》、《SQL Server查詢操作技巧大全》、《SQL Server存儲(chǔ)過程技巧大全》、《SQL Server索引操作技巧大全》、《SQL Server常用函數(shù)匯總》及《SQL Server日期與時(shí)間操作技巧總結(jié)

希望本文所述對(duì)大家SQL Server數(shù)據(jù)庫(kù)程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論