或者Select IDENT_CURRENT('table_name')

解决方案 »

  1.   

    具体跟insert的位置关系怎么样做,具体一下好吗?
      

  2.   

    恩,在插入之後得到。用這個吧Select IDENT_CURRENT('table_name')
      

  3.   

    select @@identity

    select ident_current('table_name')
      

  4.   

    在SQL查询分析器内可以得到结果,但在ASP内得不到结果.
      

  5.   

    Select IDENT_CURRENT('table_name')
      

  6.   

    可以这么写,但是执行效率不是很高
    ---------------------------------
    表temp_table
      id   U_name U_tel
       1   zhang  123456
       2   wang   123455
    ---------------------------------
    insert into temp_table(U_name,U_tel) values('li','123456')结果:
    -------------------------------
    表temp_table
      id   U_name U_tel
       1   zhang  123456
       2   wang   123455
           li     123456
    -------------------------------
    然后执行update  temp_table set [id]=(select count(*)  from temp_table) where [id] is null结果:-------------------------------
    表temp_table
      id   U_name U_tel
       1   zhang  123456
       2   wang   123455
       3   li     123456
    -------------------------------不知道是不是你要求的功能
      

  7.   

    要写成存储过程,不然会有问题insert 语句
    紧接着写
    select @@identity(可以用一个变量来付值)
    这个就是你要的,
    但一定二条语句要连着,不然有并发的时候会不准的
      

  8.   

    insert into temp_table(U_name,U_tel) values('li','123456')select @@identity as 'ID'
      

  9.   


    CReate table a (id int primary key identity(1,1),names nchar(10))
    insert into a values ('ok') select @@identity as 'id'
      

  10.   

    ASP的话,这样子行吗?rs.AddNew
    rs("U_name")='li'
    rs("U_tel")='123456'
    rs.Update
    ID=rs("id")