SQL Server 得到行号的SQL

使用临时表:

select   id=identity(int,1,1),value   into   #temp   from   YourTable  
  select   *   from   #temp  
  drop   table   #temp  

 

取得第11到20行记录:

select   IDENTITY(int,   1,1)   AS   ID_Num,*   into   #temp   from   表  
  select   *   from   #temp   where   ID_Num>10   and   ID_Num<=20

 

或  
  SELECT   Top   @PageSize   *  
            FROM   T  
          WHERE   SortField   NOT   IN   (SELECT   TOP   @PageSize   *   @Pagei   SortField  
                                                              FROM   T  
                                                      ORDER   BY   SortField  
                                                          )  
    ORDER   BY   SortField

 

REF:http://topic.csdn.net/t/20021022/21/1116380.html

 

posted @ 2008-09-22 22:27  emanlee  阅读(5045)  评论(0编辑  收藏  举报