Home Forums Database Design Relational Theory How to Add Parent Table Record Id in Child Table Using Foreign Key RE: How to Add Parent Table Record Id in Child Table Using Foreign Key

  • I'm not so sure I'd use a trigger. Those things are notorious performance and maintenance headaches.

    What about using the OUTPUT clause. You can output the IDs generated from an INSERT statement into a temp table or table variable and then use those values for the INSERT into the child table. That's the method I'll use when I need to do something like this.

    "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