--Delete only duplicate addresses on Reservations where Addresstype does not match between RA and RAX
--in order to prepare for Unique Referance, guest, address IX on RAX
DELETE FROM RESERVATIONADDRESSXTAB
FROM RESERVATIONADDRESSXTAB RAX WITH (NOLOCK) 
  INNER JOIN ReservationAddress RA WITH (NOLOCK) ON RA.AddressNumber = RAX.ADDRESSNUMBER AND RA.ADDRESSTYPE <> RAX.AddressTypeNumber
WHERE RAX.ReferenceNumber IN (
SELECT RAX.ReferenceNumber FROM RESERVATIONADDRESSXTAB RAX WITH (NOLOCK) 
GROUP BY RAX.ReferenceNumber, RAX.GUESTNUMBER, RAX.ADDRESSNUMBER 
HAVING Count(*) > 1 
)
