I need to create parent child table in my DB. My child table is already existed for a long time, so it contained a long list of records. What i want to do it copy child name to my parents table.
Child Table
--------------- ChildID | ChildNm --------------- 1 |A 2 |B 3 |C
Parent Table
---------------- ParentID|ParentNm|ChildNm ----------------
Query
WHILE (
SELECT Min(ChildID)
FROM ChildTable
) <
SELECT Max(ChildID)
FROM ChildTable
BEGIN
--INSERT every child NAME TO my parents TABLE
END
Is this the best possible way to do this?