alter table t add i int identity(1,1)

解决方案 »

  1.   

    alter table 表名 add
      列名 int identity(1,1)
      

  2.   

    Create table t(code varchar(30) Null)
    go
    insert into t
    select 'a'
    union all
    select 'b'
    union all
    select 'c'
    select * from t
    go
    alter table t add i int identity(1,1)
    go
    select * from tdrop table t(所影响的行数为 3 行)code                           
    ------------------------------ 
    a
    b
    c(所影响的行数为 3 行)
    (所影响的行数为 3 行)code                           i           
    ------------------------------ ----------- 
    a                              1
    b                              2
    c                              3(所影响的行数为 3 行)
      

  3.   

    alter table 表名 add
      列名 int identity(1,1)就可以了
      

  4.   

    alter table 表名 add
      列名 int identity(1,1)