发布于 2017-08-22 04:26:50 | 140 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的SQL Server教程,程序狗速度看过来!

SQL Server 数据库

SQL Server 即 Microsoft SQL Server 。 SQL是英文Structured Query Language的缩写,意思为结构化查询语言。SQL语言的主要功能就是同各种数据库建立联系,进行沟通。按照ANSI(美国国家标准协会)的规定,SQL被作为关系型数据库管理系统的标准语言。


这篇文章主要介绍了sql server实现分页的方法,结合实例形式总结分析了SQL Server实现分页功能的常用sql语句,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了sql server实现分页的方法。分享给大家供大家参考,具体如下:


declare @index int,@num int
set @index = 1--当前页
set @num = 2--单页包含的行数
--分页1
select top (@num) *
from ppohd
where doccode not in
(
  select top (@num * (@index -1)) doccode
  from ppohd
  order by doccode
)
order by doccode
--分页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
)
--分页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
--分页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)

希望本文所述对大家SQL Server数据库程序设计有所帮助。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务