Identity for a given table and throughout all connections?

  • Hi,

    I'm wondering about the following problem. I have a table with an identity column, and different applications that can add to this table. the problem I have is that when 2 different connections insert a new row, they each may do so before the other one has completed and committed the data.

    So my question is the following: Is there an equivalent to @@IDENTITY for a given table? IDENT_CURRENT() will not work in this case since it's not limited to the current session like IDENTITY is. I'm really looking for something that provides me with the combination of both. SCOPE_IDENT() does not really look like it's what I want either...

    Anybody has had this kind of problem? If so, how did you go about solving it?

    Thanks,

    Greg

  • Ummm... actually, Scope_IDENTITY() is exactly what you want.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Ahhh... I see. I wish I could specify a table name but this is not bad at all actually, thanks a lot!

    Jeff Moden (12/13/2007)


    Ummm... actually, Scope_IDENTITY() is exactly what you want.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply