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

推荐订阅源

GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Securelist
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
T
Threat Research - Cisco Blogs
罗磊的独立博客
IT之家
IT之家
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
K
Kaspersky official blog
博客园_首页
T
The Blog of Author Tim Ferriss
T
Tenable Blog
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
T
The Exploit Database - CXSecurity.com
D
Docker
TaoSecurity Blog
TaoSecurity Blog
S
Schneier on Security
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
M
MIT News - Artificial intelligence
U
Unit 42
N
Netflix TechBlog - Medium
L
LINUX DO - 热门话题
C
CERT Recently Published Vulnerability Notes
T
Tailwind CSS Blog
Hacker News: Ask HN
Hacker News: Ask HN
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
美团技术团队
F
Fortinet All Blogs
Last Week in AI
Last Week in AI
AWS News Blog
AWS News Blog
V
V2EX
博客园 - 【当耐特】
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
Schneier on Security
Schneier on Security
腾讯CDC
H
Help Net Security
B
Blog RSS Feed
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
The Last Watchdog
The Last Watchdog
有赞技术团队
有赞技术团队

博客园 - 过客匆匆

几个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