SQL Copy table record and all related table records linked via relationships from VB.net or C#
Posted on 2006-11-30
Hi there, I am working in VB.Net 2.0 Windows Forms with SQL 2000.
I have a requirement to copy a campaign in a our windows forms application. This involves copying the current campain record in the table plus all associate data inserting new copies of the data in all the related tables, making all new ids and records which all link back to the new campain.
Relationships back to the campaing table are all defined in SQL Server and there is currently 3 levels of tables nesting back to the campaign table via relationships.
What is the easiest and fastest way to do this?
I can use strongly typed data set and all the related tables on to it, and select the record for the campaign, but how do I select all related records in all the other tables and then copy them?
Thanks heaps, also I need this asap.