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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 单车骑客

安装vs2005 sp1 出现错误1718,文件未通过数字签名检查,解决方法 HTML:scrollLeft,scrollWidth,clientWidth,offsetWidth之完全详解(转载) 为新闻标题加颜色 - 单车骑客 - 博客园 GridView中如何做删除提示信息 GridView绑定多个参数值 - 单车骑客 - 博客园 Url重写 解决“不重新发送信息,则无法刷新新网页”的方案 - 单车骑客 - 博客园 powerdesigner将PDM转换到OOM时,code与name同时同步转换 Powerdesgner数据模型设计中,属性名同名问题的解决方法 正则表达式30分钟入门教程(转) asp.net页面生命周期 scrollWidth,clientWidth等区别 用js删除表中一行 存储过程中如何处理分页 SQL函数:分离字符串,并返回分离后字符的表 提供一个获取高精度时间类(转) SQL中,内连接,外连接的书写格式 javascript正则表达式 下拉菜单
SQL2005如何进行分页??
单车骑客 · 2008-06-27 · via 博客园 - 单车骑客

昨天需要在存储过程中进行分页的操作,以前没在SQL2005中进行分页过,据说2005含有分页的功能,网上查了一下资料,现在整理了一下,以便下次遇到时进行查阅!

create PROCEDURE [dbo].[Pro_Test]
    
-- Add the parameters for the stored procedure here
    @PageSize FLOAT,--每页显示的个数
    @TargetPage SMALLINT--目标页的索引值
AS
BEGIN
    
-- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    
-- Insert statements for procedure here
    WITH Sales_CTE(PageNumber,ID,Numb,Password,CreateDate)
    
AS(
    
select CEILING((ROW_NUMBER() OVER (ORDER By CreateDate desc))/@PageSizeas PageNumber,ID,
    Numb,Password,CreateDate 
from tbl_Wealth_WorthCard 
    )
    
select ID,Numb,Password,CreateDate from Sales_CTE
    
where PageNumber=@TargetPage

对以上存储过程进行分析一下:
with:  这条语句会调用SQL Server中的一个新属性,我们称之为common table expression(CTE),从本质上来说,我们可以将CTE看作是高版本的临时表。
分页的实质就是CTE中的TSQL语句。在下面的选择语句中,我使用了一个新的排序函数——ROW_NUMBER(这一函数很容易使用,你只需要给 ROW_NUMBER函数提供一个域名作为参数,ROW_NUMBER会用它来进行分页)。随后,我使用@PageSize参数来划分每页的行数以及每页的最大行数值。