Using @@IDENTITY in manual commit mode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Deepak

    Using @@IDENTITY in manual commit mode

    Hi,

    I'm using the JDBC API's to access a MS-SQL 2000 DB.I have a
    manual-commit transaction block involving multiple inserts and
    updates. One of the step involves retrieving the auto generated key
    (Identity column) which, I presume can be done with @@IDENTITY. My
    Question is: Will @@IDENTITY work if Auto Commit is turned off?
  • John Bell

    #2
    Re: Using @@IDENTITY in manual commit mode

    Hi

    If you are using SQL Server 2000 then the SCOPE_IDENTITY function should be
    used instead of @@IDENTITY. @@IDENTITY and SCOPE_IDENTITY will return the
    last Identity value created by that session, therefore if you have triggers
    that insert data into a table containing an identiity value it will not
    return the value you are expecting. Not using AUTO_COMMIT will not effect
    this behaviour.

    John

    "Deepak" <deepak.j@bigpo nd.com> wrote in message
    news:bfa6e05a.0 310162309.b0d77 8e@posting.goog le.com...[color=blue]
    > Hi,
    >
    > I'm using the JDBC API's to access a MS-SQL 2000 DB.I have a
    > manual-commit transaction block involving multiple inserts and
    > updates. One of the step involves retrieving the auto generated key
    > (Identity column) which, I presume can be done with @@IDENTITY. My
    > Question is: Will @@IDENTITY work if Auto Commit is turned off?[/color]


    Comment

    Working...