Do you have any way of figuring out which invoices were imported in the current batch? Perhaps by a datetime value or an external ID column? In that case you could simply do this:INSERT INTO Invoice_Item (InvoiceID, ItemID) SELECT InvoiceID, 3 FROM Invoice WHERE BatchID = @CurrentBatchID (just an example condition)INSERT INTO Invoice_Item (InvoiceID, ItemID) SELECT InvoiceID, 4 FROM Invoice WHERE BatchID = @CurrentBatchID INSERT INTO Invoice_Item (InvoiceID, ItemID) SELECT InvoiceID, 5 FROM Invoice WHERE BatchID = @CurrentBatchID (just an example condition)
This should be the quickest way to do it, but you need to have a way of identifying the latest imported records.OS