set identity_insert 我的表 on
insert 我的表
values(id,'data')
set identity_insert 我的表 off
go
select * from 我的表

解决方案 »

  1.   

    不存在的ID可以用set identity_insert 我的表 on重新插入
      

  2.   

    说白了,就是在一个表中能不能,得到第XXX行的记录啊
      

  3.   

    select identity(int,1,1) as a_id,
            a.col,a.col2,a.col3,a.col4,a.col5 into #myTable
    from yourTable
    select * from #myTable where a_id=
    drop table #myTable
    要得到某一行的话,至少要有个标识符或别限定条件,
      

  4.   

    判断ID就行了,读的时候传入ID值,只读出比传入ID大的记录就行了.
      

  5.   

    一个笨办法,但效率较低: select min(id) from you_table where id > curr_id(目前的ID)
      

  6.   

    如果要重新使ID连续,只需要删除此字段,再重建就行了.alter table 表 drop column id
    alter table 表 add id int identity(1,1)如果只是想得到第XX行记录,就用:
    select * from 表 where id=(select id from 表 group by id having count(*)=行数)--或:
    select top 1 * from(select top 行数 * from 表) order by id desc
      

  7.   

    更多的参考我的贴子:
    查询第X页,每页Y条记录
    http://expert.csdn.net/Expert/topic/2365/2365596.xml?temp=.8557245