I've got the following tables (only key columns shown):
Order OrderItem OrderItemDoc Document ======= =========== ============ ========== OrderId OrderItemId OrderItemId DocumentId --etc-- OrderId DocumentId --etc-- --etc--
I'm writing a stored procedure to 'clone' an Order (takes an existing OrderId as a parameter, copies the Order and all related items, then returns the new OrderId). I'm stuck on the 'OrderItemDoc' joining table as it will be joining two sets of newly created records. I'm thinking I'll need to loop round a temporary table that maps the old IDs to the new ones. Is that the right direction to go in? It's running on MS-SQL 2000.