V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
ylxb23
V2EX  ›  问与答

SQL Server 2012 实现分页并可以统计记录总数的实现方法

  •  
  •   ylxb23 · Jul 16, 2015 · 2978 views
    This topic created in 3947 days ago, the information mentioned may be changed or developed.
    现在已经有两个想法:
    一是,使用COUNT(*)将总数获取,再次执行 OFFSET startIndex ROWS FETCH NEXT pageSize ROWS ONLY获取分页的数据;
    二是,在查询结果集中将总数的值付给结果集中的一列即:select top 10 *,(select count(1) from table) as count from table where ......。
    求更好的方法。
    ylxb23
        1
    ylxb23  
    OP
       Jul 16, 2015
    自顶一下,求大神路过 T_T
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1165 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 23:09 · PVG 07:09 · LAX 16:09 · JFK 19:09
    ♥ Do have faith in what you're doing.