我是刚刚接触MS-SQL的,在文档里面找了很久,没有找到这个函数,使列自动增一,在MySQL里有这个函数,不知道这里该怎么实现,请各位高手指点一下!!
谢谢!!!

解决方案 »

  1.   

    类型为IDENTITY! 去帮助上搜寻这个吧!
      

  2.   

    create table a(a int identity(1,1))
      

  3.   

    eg:Create Table TEST
    (ID Int Identity(1,1),
     Name Varchar(10))
      

  4.   

    create table tb1(sn int identity(1,1),name1 char(8));
      

  5.   

    create table t(id int identity(1,1),code varchar(4))
    insert into t(code) select 'AAAA'
    insert into t(code) select 'BBBB'
    insert into t(code) select 'CCCC'
    goselect * from t
    godrop table t
      

  6.   

    create table t(id int identity(1,1),code varchar(4))
    insert into t(code) select 'AAAA'
    insert into t(code) select 'BBBB'
    insert into t(code) select 'CCCC'
    goselect * from t
    /*
    id          code 
    ----------- ---- 
    1           AAAA
    2           BBBB
    3           CCCC
    */
    godrop table t
    go