首页 > SQL Server 2005高效分页SQL语句

SQL Server 2005高效分页SQL语句

SQL2005 高效分页sql语句,需要的朋友可以参考下。

1、代码如下:
select top 10 * from
( select top (@Page * 10) ROW_NUMBER() OVER (order by id) as RowNum, id, username
from Guest where username = 'user'
) as T
where RowNum > ((@Page - 1) * 10)

2、代码如下:
select * from
( select ROW_NUMBER() OVER(order by id) as RowNum,id,username
from Guest where username = 'user'
) as T
where RowNum between 31 and 60

3、代码如下:
with T as
(select ROW_NUMBER() OVER(order by id) as RowNum,,id,username
from Guest where username = 'user'
)
select * from T
where RowNum between 31 and 60

MSSQL推荐
sysServers中找不到服务器,请执...
SQL Server存储过程中的top+...
关于SQL Server 2005使用临...
SQL Server 2008修改表结构...
SQLsever为标识列指定显式值
SQL Server 2008中SQL应...