Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Location
    Bogotá, Colombia
    Posts
    11

    Unanswered: Procedure returns wrong @@Identity

    Hi,

    I have a procedure that inserts a record to a table and return the @@Identity as an output parameter.

    This table has a trigger that is triggered when a record is inserted and add a new record to other table.

    The problem is that the @@Identity returned is totally wrong.

    Any ideas?

    Thanx in advance.

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Is it returning the identity of the record inserted via the trigger or something completely different?

    Have you tried disabling the trigger and seeing what is returned?

  3. #3
    Join Date
    Dec 2002
    Posts
    1,245

    Re: Procedure returns wrong @@Identity

    Remember that @@Identity is a global variable. It will return the Identity value that was last accessed by SQL regardless of what table it came from.

    Check @@Identity in the BOL. There is another alternative that you can use (sorry, BOL is not available to me right now) that will allow you to pull the identity value for a particular table.

    Regards,

    hmscott

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    scope_identity

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •