Retrieving ID of Inserted Record

  • Corey Mosher
    Corey Mosher

    I'm having trouble figuring out how to do this.  I have two inserts I need to perform.  The 2nd has the id of the first.  So after I insert the first I need to get the ID somehow.  Currently I'm using a select statement to do it but that doesn't seem to work out too well when I put it all inside a transaction.  I'm just curious how others have done this.  I thought about getting the next id before I do the first insert and then setting it as a parameter but I'm not so sure that will work the way I want.