Since your codes are unique, you should be able to do a loop.
Delcare the variables @CurrentID, @MaxID, @NewID
SELECT @CurrentID = (SELECT MIN( ID) FROM Table)
SELECT @MaxID = (SELECT MAX( ID) FROM Table)
WHIILE @CurrentID <= @MaxID
BEGIN
MAKE YOUR @NewID EQUAL WHATEVER CHANGES YOU WANT TO YOUR @CurrentID (the unique code you refered to).
Do your table manipulations here using the @CurrentID to match records...
SELECT @CurrentID = (SELECT MIN( ID) FROM Table WHERE ID > @CurrentID)
END
I wasn't born stupid - I had to study.