I have a database with a Parent(ParentID, ParentData) and Child (ChildID, ParentID, ChildData) table. I need to write a script that will copy both tables into a new DB but with new ParentID for both tables.
I know I could write something like:
INSERT INTO Parent(ParentID, ParentData)
SELECT newid(), ParentData FROM OtherDB.dbo.Parent
But how do I keep the children bound with the parent if I do that? Is there another, better way to do this that would allow me to keep them together?