什么意思?1:
Select identity(int,1,1) as iid,* from table1
Select * from #tmp2:如果table1有主键,比如 keyField
Select (Select sum(1) from table1 where keyField <= a.keyField) as iid,* from table1 a

解决方案 »

  1.   

    1:
    Select identity(int,1,1) as iid,* from table1
    Select * from #tmp2:如果table1有主键,比如 keyField
    Select (Select sum(1) from table1 where keyField <= a.keyField) as iid,* from table1 a
      

  2.   

    SQL SERVER企业管理器-->右键你的表-->设计表-->选中你要设置标识的字段(必须是int或其他数字类型)-->下面有个属性叫“标识”的,选“是”,你可以按你的要求改一下标识种子或标识递增量,然后保存该表的设计。或代码:
    create table 表(id int identity(1,1),name varchar(100))
    insert 表 values('J9988')
    insert 表 values('CSDNM')
    select * from 表
    drop table 表