• kabaari (8/26/2009)


    Good morning all,

    And thank i advance. I need to "UPDATE table2.ID with value from table1.ID on INSERT into table1"

    Table1.ID is Identity Insert but table2.ID is Nullable. I want when I insert values into table1 that table2 get the same ID from table for future queries.

    UPDATE tbl_Assembly_Delay1.ID

    SET tbl_Assembly_Production.ID = tbl_Assembly_Delay1.ID

    FROM tbl_Assembly_Production

    WHERE (tbl_Assembly_Production.ID = tbl_Assembly_Delay1.ID)

    Thanks again,

    DJ Khalif

    Something doesn't quite seem right here.....

    If the ID value in table2 is nullable how will you ever be able to link up table2 with table1?

    Let's follow this through the logical sequence....

    1. You insert a record into table1.

    2. You can use scope_identity() to get the identity value of the record you just inserted.

    3. So now you want to update table2's ID column with this ID you just inserted. But which row are you going to update? In other words, what conditions are you using to determine which row you want to update in table2?

    Hope that makes sense.