LIMIT 10..20 in SQL Server

后端 未结 15 2245
礼貌的吻别
礼貌的吻别 2020-11-22 11:21

I\'m trying to do something like :

SELECT * FROM table LIMIT 10,20

or

SELECT * FROM table LIMIT 10 OFFSET 10
15条回答
  •  无人及你
    2020-11-22 11:41

    A good way is to create a procedure:

    create proc pagination (@startfrom int ,@endto int) as
    SELECT * FROM ( 
      SELECT *, ROW_NUMBER() OVER (ORDER BY name desc) as row FROM sys.databases 
     ) a WHERE a.row > @startfrom and a.row <= @endto
    

    just like limit 0,2 /////////////// execute pagination 0,4

提交回复
热议问题