Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Stripping characters

Does anyone know how to strip characters in a phone number field
222-222-2222 (I would like to remove the dashes)
Please help
[143 byte] By [Sheryl Kemp] at [2007-11-9 21:11:08]
# 1 Re: Stripping characters
"Sheryl Kemp" <dianedinero@aol.com> wrote:
>
>Does anyone know how to strip characters in a phone number field
>
>222-222-2222 (I would like to remove the dashes)
>
>Please help
>

you don't say what database you're using

in Oracle you would say

select replace('123-456-789','-','') from dual

I think SQL Server is the same
mister pants at 2007-11-11 23:51:45 >
# 2 Re: Stripping characters
yes it is the same in SQL Server:

select replace('123-456-789','-','') returns 123456789

HTH,
Dave
"mister pants" <mister_pants@hotmail.com> wrote in message
news:3e478542$1@tnews.web.dev-archive.com...
>
> "Sheryl Kemp" <dianedinero@aol.com> wrote:
> >
> >Does anyone know how to strip characters in a phone number field
> >
> >222-222-2222 (I would like to remove the dashes)
> >
> >Please help
> >
>
> you don't say what database you're using
>
> in Oracle you would say
>
> select replace('123-456-789','-','') from dual
>
> I think SQL Server is the same
David Satz at 2007-11-11 23:52:53 >
# 3 Re: Stripping characters
"Sheryl Kemp" <dianedinero@aol.com> wrote:
>
>Does anyone know how to strip characters in a phone number field
>
>222-222-2222 (I would like to remove the dashes)
>
>Please help
>
Best answer is already provided, but you could also do string manipulation
like...

SELECT LEFT(phoneNumber,3)
+ SUBSTRING(phoneNumber,5,3)
+ RIGHT(phoneNumber,4)
FROM [dbo].[table_name]
Les B at 2007-11-11 23:53:45 >