方法1: 创建表时同时设置主键自增
create table <表名> (
<字段1-主键自增> int identity (1,1) primary key,
<字段2> varchar(100) unique,
.....
)
方法2: 重新添加一列具有identity属性字段(因自增列不能修改)
alter table <表名> drop column <自增字段名>
alter table <表名> add <自增字段名> int identity(1,1)