SQL Server Performance

Trigger

Discussion in 'General Developer Questions' started by Reddy, Sep 20, 2005.

  1. Reddy New Member

    Can I write a trigger that fires like..
    when new rows(5) are inserted into a table,I want the IDENTITY values of this 5 rows to be inserted into its child table where it has the same column as FK.
    If its possbile to write a trigger,can any one help how to do tht?

    Thanks!
    "He laughs best who laughs last"

  2. merrillaldrich New Member

    What are you trying to do? I have a hunch this is not the right approach, but don't have much information to go on...

    The normal way to insert things in SQL Server is like this:

    BEGIN TRANSACTION

    Insert into parent table one record

    get the ID using scope_identity()

    Insert child records with FK = the id

    roll back if something did not work

    otherwise

    COMMIT TRANSACTION

    ???

Share This Page