August 16, 2006 at 8:43 am
I have a phone field I need to validate. I need to remove periods, commas, dashes from the phone numbers.
Does anyone know how to write this query?
Thanks,
Ninel
August 16, 2006 at 8:51 am
A simple approach would be to just use the REPLACE function nested like below.
select replace(replace(replace(@phone, '.', ''), '-', ''), ',', '')
store this in a function on the server and reuse in your query...
Chuck
August 16, 2006 at 9:53 pm
No need for a function if you want to permanently correct the data...
UPDATE yourtable
SET phonenumbercol = REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
phonenumbercol
,',','')
,'-','')
,'.','')
,'(','')
,')','')
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply