declare @Row1 int
declare @row2 int
select @Row1 = 10, @Row2 = 20declare @sql varchar(7000)
select @sql = "select top " + Cast((@Row2-@Row1) as varchar(10)) + 
" * from (select top " + Cast(@Row2 as varchar(10)) + " from t1 order by f1) t
  order by f1 desc "Exec(@sql)

解决方案 »

  1.   

    select identity(int,1,1) RowID, T.* into #Tmp From Table T
    Select Col1,col2,col3 ... from #Tmp where RowID between @XX and @YY
      

  2.   

    表中有没有一个字段的值在表中是不重复的,如果有的话就好办.
    用:
    select top xx2 * from tb
       where 关键字段 not in (select top xx1 关键字段 from tb)其中:
    关键字段就是你表中值唯一的字段,只需要不重复就行了,不管是什么.
    这个语句是从第:xx1+1 条记录开始,共取 xx2 条记录
      

  3.   

    例如,取表中的第15到25条记录,则:xx1=14,xx2=10:
    select top 10 * from tb
       where 关键字段 not in (select top 14 关键字段 from tb)如果你的表中连这种字段都没有,就只好用:
    select identity(int,1,1) ID, t.* into #tmp From tb
    select * from #tmp where ID between 15 and 20