• Problem is, if another insert occurs on the master table before you get to your detail table, IDENT_CURRENT will not return the one you want. In order to do this, you need to do one of two things, get the identity when you insert the value using SCOPE_IDENTITY and then pass that as a parameter to this new procedure. But, that's limiting because you'll only be able to insert one row at a time. To be able to support multiple rows, you'll need to use the OUTPUT clause of the INSERT statement. That will allow you to capture identity values for more than one row.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning