zoukankan      html  css  js  c++  java
  • 写了一个分页存储过程把总记录数也写到返回表的每行了

    ALTER PROCEDURE [dbo].[a_Example]
     @startIndex INT ,--每页的开始记录的索引
     @pageSize INT --每页记录数
    AS
    --取出记录总数 插入@RecordCountTable临时表
    declare @RecordCountTable table(RecordCount int)
    insert into @RecordCountTable SELECT count(*) AS RecordCount FROM InOut_InOut_InOutBed
    --直接用
    begin
     select * from
        (
          SELECT row_number() OVER (ORDER BY InOutBedID DESC)AS Row,*
       from
            InOut_InOut_InOutBed
       LEFT JOIN
            @RecordCountTable ON 1=1
     )
        as
          TemporaryTable
     where
       row between @startIndex and @startIndex+@pageSize-1
    end

    或者:
    ALTER PROCEDURE [dbo].[a_Example]
     @startIndex INT ,--每页的开始记录的索引
     @pageSize INT --每页记录数
    AS
    --取出记录总数 插入@RecordCountTable临时表
    declare @RecordCountTable table(RecordCount int)
    insert into @RecordCountTable SELECT count(*) AS RecordCount FROM InOut_InOut_InOutBed
    --虚拟视图
    begin
    --取出内容 每行左连记录总数 虚拟视图orderList
    WITH orderList AS
    (
    SELECT row_number() OVER (ORDER BY InOutBedID DESC)AS Row,*
    from InOut_InOut_InOutBed
    LEFT JOIN @RecordCountTable ON 1=1
    )
    --取出虚拟视图orderList中分页内容
    SELECT *
    FROM orderlist
    WHERE row between @startIndex and @startIndex+@pageSize-1
    end

  • 相关阅读:
    lightoj1140_数位dp
    lightoj1057_状压dp
    lightoj1068_数位dp
    lightoj1018_状压dp
    lightoj1217_简单dp
    lightoj1119_简单状压dp
    lightoj1037_状压dp
    lightoj1110_LCS并输出
    图论算法----最短路
    poj1182 食物链
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/616679.html
Copyright © 2011-2022 走看看