上一条:
select max(主键列) from 你的表 where 主键列 < 你刚刚查出的主键值下一条:
select min(主键列) from 你的表 where 主键列 > 你刚刚查出的主键值

解决方案 »

  1.   

    下一条的 
    select   top 1 * from table where 主键>
    上一条 
    select top 1 *  from table where 主键<  order by 主键 desc
    或者
    alert table add column id(int ,identity(1,1))
     
      

  2.   

    我想知道SQLserver中有没有隐藏的自增主键。
      

  3.   

    没有,可以alert table add column id(int ,identity(1,1))
     增加
      

  4.   

    你可以通过#TEMPTABEL,加入你需要的排序和identity(1,1) 字段,通过该表进行定位!
    不过用游标是一个比较安全和正统的方法.
      

  5.   

    下一条的 
    select   top 1 * from table where 主键>
    上一条 
    select top 1 *  from table where 主键<  order by 主键 desc
    不行吗
      

  6.   

    to tjan:主要是我的主键是不规则的字符组成,不存在大小问题。