我想建立一个编号列,并且想让其自增,初始值是200600001,增量为1,200600002,200600003……这样下去。但我想到了2007年1月1日让编号自动(手动也可以)变为200700001,然后200700002,200700003,到了2008年也一样重新赋初始值。
请问这个该怎么实现?

解决方案 »

  1.   

    create table ta(id int identity(1,1),name nvarchar(5))
    insert into ta select 'a'
         union all select 'B'
         union all select 'C'
         union all select 'D'set identity_insert ta on
     insert into ta (id,name) values (7,'F')
    set identity_insert ta off
    select * from tadrop table taresults:
    ------------------------------
    1 a
    2 B
    3 C
    4 D
    7 F
      

  2.   

    请问到了2007年用用DBCC CHECKIDENT (Ta, RESEED, 20070000)行不行?这个命令到底怎么用?
      

  3.   

    因为数据都是前端输入的,我不想用insert