INSERT INTO returns the IDENTITY value

  • I am using INSERT INTO statement to insert set of values into a table which has an identity column.

    When I run the statement, it returns the latest identity value.

    How can I turn this OFF?

    Thanks,

  • I don't believe it's returning the the latest identity value unless someone put a trigger on the table that does so.  Check to see if there are any triggers on the table... you might not want to turn off such a trigger because it may mess up what a GUI is expecting.

    To temporarily disable a trigger, use the following...

    ALTER TABLE tablenamehere DISABLE TRIGGER triggernamehere

    To turn it back on, use the following...

    ALTER TABLE tablenamehere ENABLE TRIGGER triggernamehere

    But, like I said, it might not be a trigger... maybe it's just the rowcount you are seeing... if so, you can turn that off with the following...

    SET NOCOUNT ON

    --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)

  • You are Right! I had created a trigger on the table while testing and forgot about it.

    Thanks so much.

     

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

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