zoukankan      html  css  js  c++  java
  • Sqlserver2005 with as 实现分页以提高性能

    1。在sqlserver中建一个存储过程,代码如下:


    create proc GetRows
    @begin as int,
    @end as int
    as
    begin
       
    with result as
       (
         
    select row_number() over(order by book_id descas rowindex,book_name,price from book
       )
     
    select * from result where rowindex between @begin and @end
    end

    通过with as 以提高性能,配合AspnetPager控件来实现分页,适合sql2005。

    在sql2000中可以这样写


    create proc GetRows2
    @begin as int,
    @end as int
    as
    begin
       
    declare @table as table (rowindex  int identity(1,1),bookName  varchar(50),price  money)
       
    insert into @table select book_name,price from book order by book_id
       
    select * from @table where rowindex between @begin and @end 
    end
  • 相关阅读:
    Redis
    cut
    grep
    MySQL中EXPLAIN的解释
    MySQL数据类型
    有用的MySQL语句
    mysql函数
    memcache
    存储过程 游标的使用
    存储过程批量删除
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/1531341.html
Copyright © 2011-2022 走看看