Clone DB table row through MVC in SQL Server
Posted
by sslepian
on Stack Overflow
See other posts from Stack Overflow
or by sslepian
Published on 2010-03-24T04:33:06Z
Indexed on
2010/03/24
6:13 UTC
Read the original article
Hit count: 303
Is there a simple solution for duplicating table rows in SQL Server as well as all table rows with foreign keys pointing to the cloned table row? I've got a "master" table and a bunch of "child" tables which have a foreign key into the ID of the master table. I need to not only create a perfect copy of the master table, but clone each and every child table referencing the master table. Is there a simpler way to do this than creating a new row in the master table, copying in the information from the row to be cloned, then going through each child table and doing the same with each row pointing to the cloned row in the master table?
I'm using a SQL Server 2005 Database accessed through C# ASP.net MVC 1.0.
© Stack Overflow or respective owner