Contacts

Delete Phone Number

This query deletes a specified phone number from all records in the contact table.

BEGIN TRANSACTION
UPDATE Contact
SET 
homePhone = CASE WHEN homePhone = '(555)555-5555' THEN NULL ELSE homePhone END,
workPhone = CASE WHEN workPhone = '(555)555-5555' THEN NULL ELSE workPhone END,
cellPhone = CASE WHEN cellPhone = '(555)555-5555' THEN NULL ELSE cellPhone END
WHERE homePhone = '(555)555-5555' OR workPhone = '(555)555-5555' OR  cellPhone = '(555)555-5555'
ROLLBACK TRANSACTION
--COMMIT TRANSACTION