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

推荐订阅源

F
Fortinet All Blogs
V2EX - 技术
V2EX - 技术
The Last Watchdog
The Last Watchdog
宝玉的分享
宝玉的分享
T
Tenable Blog
WordPress大学
WordPress大学
K
Kaspersky official blog
Microsoft Security Blog
Microsoft Security Blog
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Hacker News - Newest:
Hacker News - Newest: "LLM"
P
Palo Alto Networks Blog
Help Net Security
Help Net Security
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
C
CXSECURITY Database RSS Feed - CXSecurity.com
A
Arctic Wolf
Forbes - Security
Forbes - Security
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog
H
Hacker News: Front Page
W
WeLiveSecurity
博客园 - 【当耐特】
G
Google Developers Blog
Martin Fowler
Martin Fowler
TaoSecurity Blog
TaoSecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
人人都是产品经理
人人都是产品经理
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
AI
AI
N
Netflix TechBlog - Medium
C
Cisco Blogs
I
Intezer
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
G
GRAHAM CLULEY
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
MyScale Blog
MyScale Blog
L
Lohrmann on Cybersecurity
Engineering at Meta
Engineering at Meta

博客园 - 世之云枭

网站技术分享 网页内容抓取 推广:湖南省德谦新材料有限公司 Http://www.paint123.cn CentOS MySQL安装和编译【转帖】 缓存容器类的实现(C#) ReadFreeCache 设计一个高效的网络服务器用户管理类 修改自增字段 C++、Java与C#的命名规范总结 (转) VTL-vm模板的变量用法 - 世之云枭 - 博客园 http://www.cnblogs.com/onlytiancai/archive/2009/04/11/1433456.html 数据库中与c#中的数据类型对照 - 世之云枭 - 博客园 SessionID的正确说明 临时文件 细节决定成败 NVelocity 主从表 自动生成清空数据库的SQL语句 自动生成Insert数据的SQL脚本 常用的获取最大值
分页存储过程
世之云枭 · 2008-07-07 · via 博客园 - 世之云枭

create PROCEDURE [dbo].[tp_Fetch_List]( 
  @page_num                INT,
  @row_in_page             INT,
  @order_column            VARCHAR(50),
  @row_total               INT  OUTPUT,
  @comb_condition          VARCHAR(500),
  @tablename      nvarchar(200)
)
AS
BEGIN
    SET NOCOUNT ON

    DECLARE
      @jcc_status             INT,
      @sql                  NVARCHAR(4000),
      @row_ahead        INT
    
  SET @jcc_status = 0
 

  SET @row_ahead = (@page_num-1) * @row_in_page


SET @sql='SELECT TOP '+ cast(@row_in_page as varchar(255)) +  ' * FROM ( '
SET @sql = @sql + 'SELECT   *

FROM  '+@tablename+' 
 ) as A where 1=1'

IF LEN(@comb_condition)>0
        SET @sql = @sql + ' AND (' + @comb_condition  + ')'   

SET @sql = @sql + 'and ID not in ( select ID from ('
SET @sql = @sql + 'SELECT TOP ' + cast(@row_ahead as varchar(255)) + ' * From ('
SET @sql = @sql + 'SELECT   *

FROM '+@tablename+'
 ) as A where 1=1'
    IF LEN(@comb_condition)>0
        SET @sql = @sql + ' AND ( ' + @comb_condition  + ' )'   

    IF LEN(@order_column)>0
        BEGIN
            SET @sql = @sql + ' ORDER BY ' + @order_column    + ' ) AS B )'
        END
    ELSE
        BEGIN
            SET @sql = @sql + ' ) AS B )'
        END

    IF LEN(@order_column)>0
        BEGIN
            SET @sql = @sql + ' ORDER BY ' + @order_column    
        END

 print @sql

    EXEC (@sql)

    SET @sql= N'SELECT @row_total=COUNT(*) FROM ('
SET @sql = @sql + 'SELECT  *

FROM '+@tablename+'
 ) as A where 1=1'
IF LEN(@comb_condition)>0
        SET @sql = @sql + ' AND (' + @comb_condition  + ')'   

print @sql

    EXEC sp_executesql @sql,N'@row_total INT OUT',@row_total OUT

    IF @@ERROR != 0
    BEGIN
        SELECT @jcc_status = -98
    END


exit_bk:

-- exit with MS SQL Server error
  IF @jcc_status = -98
    BEGIN
      RAISERROR ('MS SQL Server error, please contact your system administrator.',16,1)WITH NOWAIT
      RETURN (@jcc_status)
    END

-- normal exit
  RETURN (0)
END

GO