alter table 表 add 编号 int identity  --编号设置成标识列

解决方案 »

  1.   

    增加自增列的语句:
    alter table tabname add column colname int identity(1,1) not null如果表里已经存在数据,不能如此操作,借助临时表
    select * from tabname into #newtabtruncate table tabnamealter table tabname add column colname int identity(1,1) not nullinsert into tabname() select * from #newtabdrop table #newtab
      

  2.   

    增加自增列的语句:
    alter table tabname add colname int identity(1,1) not null