本文實(shí)例講述了sql server實(shí)現(xiàn)分頁(yè)的方法。分享給大家供大家參考,具體如下:
declare @index int,@num intset @index = 1--當(dāng)前頁(yè)set @num = 2--單頁(yè)包含的行數(shù)--分頁(yè)1select top (@num) *from ppohdwhere doccode not in( select top (@num * (@index -1)) doccode from ppohd order by doccode)order by doccode--分頁(yè)2select top (@num) *from ppohdwhere doccode >=( select max(doccode) from ( select top (@num * (@index - 1) + 1) doccode from ppohd order by doccode ) as tb)--分頁(yè)3select top (@num) *from( select ppohd.doccode as 'mydoccode',row_number() over (order by doccode) as sno,* from ppohd) as tbwhere tb.sno >= @num * (@index - 1) + 1--分頁(yè)4select *from( select ppohd.doccode as 'mydoccode', row_number() over(order by doccode) as sno,* from ppohd) as tbwhere tb.sno between (@num * (@index - 1) + 1) and (@num * @index)
希望本文所述對(duì)大家SQL Server數(shù)據(jù)庫(kù)程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選