UPDATE WF_MilestoneRule 
SET [ParentId] = (SELECT t2.ID 
                  FROM WF_MilestoneRule t2 join WF_MilestoneRule t3 on t2.ParentID = t3.MilestoneCreatedById
                  WHERE t1.MilestoneCreatedById = t2.ID
                  AND t2.ParentID is not null )
FROM WF_MilestoneRule t1
WHERE t1.AdminFolderId = @FolderId
AND t1.ParentID = 0