I have the following schema:
Parcels Segments SegmentsParcels
========= ========== =================
ParcelID SegmentID ParcelID
... Name SegmentID
... id
A user of the data wants to consolidate Segments.Names and gave me a list of current Segment.Names mapped to new Segment.Names (all of which currently exist).
So now I have this list in a temporary table with the currentID and newID to map to.
What I want to do is update the SegmentID in SegmentsParcels based on this map. I could use the statement:
update SegmentParcels set segmentID = [newID] from newsegments where segmentID = currentid
but this will create some duplicates I have a unique constraint on ParcelID and SegmentID in SegmentParcels.
What is the best way to go about this? I considered removing the constraint and then dealing with removing the duplicates (which I did at one point and could probably do again) but I was hoping there was a simpler way.