SqlServer 2008R2 分页查询语句写法

SqlServer 2008R2分页新写法

--以前的写法-必须借助row_number()函数来获取行的序列号
Select *
from 
(
    select 
    ROW_NUMBER() over(order by name asc)  as __tempId,
    * From (select t.*  from student t)as a
)as a
Where a.__tempId between 1 And 10
--现在的写法-用offset 与 fetch next 来处理
select t.*
from student t
order by t.name asc
offset 0 rows fetch next 10 rows only   

你可能感兴趣的:(SqlServer)