@@IDENTITY
Returns the last-inserted identity value.

解决方案 »

  1.   

    id 是自增??Select @@IDENTITY
      

  2.   

    declare @id int
    insert into tab_name(字段列表) values (值列表)
    select @id = @@identity
      

  3.   

    本人比较菜,select @id = @@identity怎么用啊
      

  4.   

    我是用vc连的sqlserver ,在vc中怎么取这个id值,help!!
      

  5.   

    如果你的ID是自增的,在你执行完insert后,执行Select @@IDENTITY就可以获得新插入的ID。
      

  6.   

    Select @@IDENTITY或
    declare @id int
    select @id=max(id) 
    from tablename
    set @id=@ida+1
      

  7.   

    要不建立一個虛擬字段。
    declare @id int
    select identity(int,1,1) IDD ,* into #temp 
    from tablenameselect @id=id 
    from tablename IDD in(select max(IDD) from tablename)set @id=@id+1
      

  8.   

    @id加一就在插入數據時提前知道此ID的值看情況而定要不要加1
      

  9.   

    declare @id
    select @id=id from insertedinsered 是一张特殊的表,保存有你刚插入或修改的记录的副本