Update Patron Phone Numbers for Long Distance Changes
**!! BE VERY CAREFUL WITH THIS ONE !!**
You will also need to run this query three times. Once for PhoneVoice1 and again for PhoneVoice2 and a third time for PhoneVoice3.
Big thanks again to Gabrielle!
/* Run this first part on its own so you make sure you're getting back data that makes sense. */
SELECT
pr.PatronID,
pr.PhoneVoice1,
RIGHT(pr.PhoneVoice1,12) AS [NewPhoneVoice1]
INTO
Polaris.Polaris.TempPhoneUpdate
FROM
Polaris.Polaris.PatronRegistration pr WITH (NOLOCK)
WHERE
pr.PhoneVoice1 LIKE '1%'
AND
LEN(pr.PhoneVoice1) = 14 -- THIS NUMBER MAY NEED ADJUSTMENT
/*
Next you update the new phone numbers in the temp table to the live patron registration numbers.
I've commented out the UPDATE for safety.
*/
-- UPDATE
Polaris.Polaris.PatronRegistration
SET
PatronRegistration.PhoneVoice1 = TempPhoneUpdate.NewPhoneVoice1
FROM
Polaris.Polaris.TempPhoneUpdate
WHERE
PatronRegistration.PatronID = TempPhoneUpdate.PatronID
DROP TABLE Polaris.Polaris.TempPhoneUpdate