惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Privacy International News Feed
T
Tor Project blog
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
Lohrmann on Cybersecurity
博客园_首页
T
Tailwind CSS Blog
A
Arctic Wolf
P
Proofpoint News Feed
H
Help Net Security
V
Vulnerabilities – Threatpost
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
F
Fortinet All Blogs
罗磊的独立博客
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
D
DataBreaches.Net
博客园 - 聂微东
Security Latest
Security Latest
V
Visual Studio Blog
腾讯CDC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cyberwarzone
Cyberwarzone
T
Tenable Blog
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
N
Netflix TechBlog - Medium
The Cloudflare Blog
U
Unit 42
Latest news
Latest news
AWS News Blog
AWS News Blog
J
Java Code Geeks
N
News and Events Feed by Topic
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security

博客园 - 过客匆匆

几个Javascript函数 - 过客匆匆 - 博客园 一个在vbscript中读取cookie的程序函数 ASP2HTML WITH TEMPLET [转载] 惊云下载系统里的html文件生成方法 - 过客匆匆 - 博客园 [转载]网站生成静态页面攻略 用Visual C#打造多页面网页浏览器 嵌套使用DATAList 漫谈ASP.NET设计中的性能优化问题 ASP生成静态网页的方法 令网站打开提高速度的7大秘方 ASP.NET 格式化字符串(转) 选项卡 注册时倒计时的东西 天气预报代码 asp.net中让服务器端控件获得焦点 ACCESS数据库的压缩,备份,还原,下载,删除的实现 无效的 CurrentPageIndex 值 一个比较实用的大数据量分页存储过程 动态ASP网站生成HTM、HTML静态网站方法 模板生成静态页面
数据库存储过程分页显示
过客匆匆 · 2006-03-25 · via 博客园 - 过客匆匆

*
经测试,在 14483461 条记录中查询第 100000 页,每页 10 条记录按升序和降序第一次时间均为 0.47 秒,第二次时间均为 0.43 秒,测试语法如下:
exec GetRecordFromPage news,newsid,10,100000
news 为 表名, newsid 为关键字段, 使用时请先对 newsid 建立索引。
*/

/*
函数名称: GetRecordFromPage
函数功能: 获取指定页的数据
参数说明: @tblName 包含数据的表名
@fldName 关键字段名
@PageSize 每页记录数
@PageIndex 要获取的页码
@OrderType 排序类型, 0 - 升序, 1 - 降序
@strWhere 查询条件 (注意: 不要加 where)
作  者: 铁拳
邮  箱: unjianhua_kki@sina.com">sunjianhua_kki@sina.com
创建时间: 2004-07-04
修改时间: 2004-07-04
*/
Create PROCEDURE GetRecordFromPage
@tblName varchar(255), -- 表名
@fldName varchar(255), -- 字段名
@PageSize int = 10, -- 页尺寸
@PageIndex int = 1, -- 页码
@OrderType bit = 0, -- 设置排序类型, 非 0 值则降序
@strWhere varchar(2000) = '' -- 查询条件 (注意: 不要加 where)
AS

declare @strSQL varchar(6000) -- 主语句
declare @strTmp varchar(1000) -- 临时变量
declare @strOrder varchar(500) -- 排序类型

if @OrderType != 0
begin
set @strTmp = "<(select min"
set @strOrder = " order by [" + @fldName +"] desc"
end
else
begin
set @strTmp = ">(select max"
set @strOrder = " order by [" + @fldName +"] asc"
end

set @strSQL = "select top " + str(@PageSize) + " * from ["
+ @tblName + "] where [" + @fldName + "]" + @strTmp + "(["
+ @fldName + "]) from (select top " + str((@PageIndex-1)*@PageSize) + " ["
+ @fldName + "] from [" + @tblName + "]" + @strOrder + ") as tblTmp)"
+ @strOrder

if @strWhere != ''
set @strSQL = "select top " + str(@PageSize) + " * from ["
+ @tblName + "] where [" + @fldName + "]" + @strTmp + "(["
+ @fldName + "]) from (select top " + str((@PageIndex-1)*@PageSize) + " ["
+ @fldName + "] from [" + @tblName + "] where " + @strWhere + " "
+ @strOrder + ") as tblTmp) and " + @strWhere + " " + @strOrder

if @PageIndex = 1
begin
set @strTmp = ""
if @strWhere != ''
set @strTmp = " where (" + @strWhere + ")"

set @strSQL = "select top " + str(@PageSize) + " * from ["
+ @tblName + "]" + @strTmp + " " + @strOrder
end

exec (@strSQL)

GO