First of all you have to update TableA before removing the duplicates in TableB. If not, you are gonna lose information.
After that, make all the duplicates in table B equal in one field (let's say LocationDescription)
Then, select one LocationID of all them. Let´s say the MIN Location ID.
After that, update tableA with that MinID and then remove from TableB the duplicates in a really easy way (with a NOT in).
Here´s an example:
Asumming
TableA: Table B
Location ID LocationId LocationDescription
1 1 Neuquen
2 2 Cipolletti
3 3 Neuquen
4 4 Cipolletti
5 5 Neuquen
UPDATE TableA
SET locationID=TABLEBAUX.UniqueID
FROM TableA
INNER JOIN
(
SELECT UniqueID, LocationID
FROM
(SELECT MIN(LocationID) as UniqueID,LocationDescription
FROM TableB
GROUP BY LocationDescription) TEMP
INNER JOIN TableB
ON TEMP.LocationDescription=TABLEB.LocationDescription) TABLEBAUX
ON TableA.LocationID=TABLEBAUX.LocationID
DELETE FROM TableB
WHERE LocationID NOT in (SELECT LocationID FROM TABLEA)
After this you get this:
TableA: Table B
Location ID LocationId LocationDescription
1 1 Neuquen
2 2 Cipolletti
1
2
1