Ok I think I will need to use a temp table for this and there is no code to share as of yet. Here is the intent.I need to insert data into two tables (a header and detail table) the Header Table will give me lets say an order number and this order number needs to be placed on the corresponding detail lines in the detail table.Now if I were inserting a single invoice with one or more detail lines EASY, just set @@Identity to a variable and do a second insert statement. What is happening is I will be importing a ton of Invoice headers and inserting those into the header table. The details are already in the database across various tables and and I will do that insert based on a select with some joins. As stated I need to get the invoice number from IDENTITY of the header table for each DETAIL insert.I am assuming the only way to do this is with a loop... Insert one header, get identity; Insert the detail table and include the IDENTITY variable, and repeat.Please let me know if there is a set-based approach to this.
↧