Can anyone suggest a decent strategy for copying (potentially) large amounts of data into the same tables in a database ?
To explain, I have a database which holds estimate details in a number of related tables. The client would like a facility to copy an estimate, creating a clean version which can be modified leaving the source estimate untouched.
Obviously the copied data would need to maintain the relations between parent and child rows, so I assume bulk copy is not viable.
The application is .NET, and it has been suggested that the only way is to load a DataSet with the source estimate, then insert the rows back into the database, retrieving the keys as each row is inserted. The child rows would then have the foreign key value updated before they were inserted.
This seems an inefficient way to copy data, so any suggestions would be greatly appreciated.
To explain, I have a database which holds estimate details in a number of related tables. The client would like a facility to copy an estimate, creating a clean version which can be modified leaving the source estimate untouched.
Obviously the copied data would need to maintain the relations between parent and child rows, so I assume bulk copy is not viable.
The application is .NET, and it has been suggested that the only way is to load a DataSet with the source estimate, then insert the rows back into the database, retrieving the keys as each row is inserted. The child rows would then have the foreign key value updated before they were inserted.
This seems an inefficient way to copy data, so any suggestions would be greatly appreciated.