SQL2000与SQL2005下高效分页语句

SQL SERVER 2000:

1  select   top   30   *   from  users
2  where  userid < ( select   min (userid)  from  ( select   top   900000  userid  from  users  order   by  userid  desc as  tmp) 
3  order   by  userid  desc


 SQL SERVER 2005:

1  select   *   from  (
2       select  row_number()  over ( order   by  userid  desc ) RowNumber, *
3       from  ( select   top   900030  userid from  users )  as  t
4  as  tt
5  where  RowNumber > 900000


 userid为索引字段,users为表名

转载于:https://www.cnblogs.com/tacker/archive/2010/06/19/1761049.html

你可能感兴趣的:(SQL2000与SQL2005下高效分页语句)