Home Forums Programming General Linked Primary Keys after INSERT within the same table RE: Linked Primary Keys after INSERT within the same table

  • TBIG (6/23/2013)


    I need to do an INSERT for a subset of records in a table to the same table. What is the best way to determine the primary key of the source record from an inserted record?

    You can add a nullable column to the table called something like Parent_ID. If the row originated from another row, then Parent_ID would be populated with the original row's ID. If Parent_ID is NULL, then it's an original row.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho