Home Forums SQL Server 7,2000 T-SQL Which one to use among Ident_Current,Scope_Identity and @@Identity? RE: Which one to use among Ident_Current,Scope_Identity and @@Identity?

  • I am new to sql server and I need your suggestions:

    which one is the best for PK generation(@@IDENTITY, SCOPE_IDENTITY, and IDENT_CURRENT ). If i have transactions like this.

    begin tran

    Insert into customer(id,fname,lname) (4,'sameer','dutts')

    @cid=SCOPE_IDENTITY --cid will be 4

    Insert into address (adrsid,customerid,'addressvalue')(1,4,'dutts')

    end tran

    for such transactions what identity variable we should use.

    Does begin tran end tran makes the current scope to return the correct identity value.Pls let me know asap.