select * into #temp from table
alter table #temp 
add column id int identity not null
select * from #temp where id between 10 and 20

解决方案 »

  1.   

    1、
    select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
    select * from #temp where ID_Num>10 and ID_Num<=202、
    exec('SELECT Top '+cast(@PageSize as varchar)+' * FROM T WHERE SortField NOT IN (SELECT TOP '+cast(@PageSize* @Pagei as varchar)+' SortField from T )')
      

  2.   

    好像没有类似top 10得简单的办法啊, 那就揭帖啦。
      

  3.   


    查询N-M条记录。
    select IDENTITY(int,1,1) as iid,* into #temptable from yourtable
    select top M-N * from #temptable where iid>=NOR:select top M-N * from yourTable where id not in(select top N-1 id from table)
    ID为表具有唯一值的任何字段
      

  4.   

    select top 10 * from #temp where id not in (select top 20 id from #temp)select * from (select top 20 * from table order by id) a where id not in (select top 9 id from table order by id)
      

  5.   

    select * from (select top 10 * from (select top 20 from table order by keyfield)  order by keyfield desc) order by keyfield顺便声明一下,因为没看清搂主意图,取消在《关于查询重复记录的问题?》中的发言。
      

  6.   

    select identity(int,1,1) as id ,* into #kk from 表
    select * from #kk where id between 10 to 20
      

  7.   

    select * into #temp from table
    alter table #temp 
    add column id int identity not null
    select * from #temp where id between 10 and 20
    drop #temp
      

  8.   

    你了可以将10和20作为变量,取位置从n-m到n的记录。
      

  9.   

    取从@m之后到@n的记录:set @s='select * from (select top '+cast(@n-@ as varchar)+' * from (select top '+cast(@n)+' from table order by keyfield)  order by keyfield desc) order by keyfield
      

  10.   

    w_rose: 原闻其祥,如可行你的分数另结。
      

  11.   

    w_rose: 执行出错。能不能把语句写清楚点,一下子看不明白。
      

  12.   

    呵呵,终于结贴成功了。w_rose:你的意思我明白,请到 http://expert.csdn.net/Expert/topic/1609/1609102.xml?temp=.3438379另行领分。