写一个触发器,每insert一行则把自动编号加1

解决方案 »

  1.   

    1.
    用标识字段,下面的语句为你的表增加名为ID且自动编号的主键:alter table 你的表 add id int identity(1,1) not null  constraint PK_sys_zj_fielddict primary key clustered
      

  2.   

    右击表——〉设计表——〉插入一个字段id int——〉将标识 属性设为 是 标识种子 设为1 标识地增量 设为1
    这样就可以实现自动编号的功能了
      

  3.   

    2.
    在新增数据时,自动将最大编号加上,即新增时用下面的方法:
    insert into 你的表
        select isnull(max(id),0)+1,其他字段的值列表 from 你的表