ms sql中没有
临时表,加个id字段
select id=identity(int,1,1),* into temp from tb
select * from temp where id>=3 and id<=7
drop table temp

解决方案 »

  1.   

    表中取出第 n 条到第 m 条的记录
    SELECT TOP m-n+1 * 
    FROM tablename 
    WHERE (id NOT IN 
         (SELECT TOP n-1 id 
         FROM tablename))
      

  2.   

    Create Proc getRangeRecs   
    (@strSQL nvarchar(4000),  
     @recStart int=1,  --这里的m  
     @recEnd int=999999)--这里的n(n>=m)  
    As  
    begin  
      set nocount on  
      declare @p1 int  
      declare @recCount int  
      set @recCount=@recEnd-@recStart+1  
     exec sp_cursorOpen @p1 output, @strSQL  
     exec sp_cursorFetch @p1,16,@recStart ,@recCount   
     exec sp_cursorClose @p1  
    end  
      

  3.   

    调用示例
    use master 
    getRangeRecs 'select * from sysobjects',1000,2000即从1000行开始取出(2000-1000+1)条记录