From: Greg Berthume on
I can't remember how I did this before and not having much success with my
syntax.

I just want to do a simple search and replace of all dashes in a field with
a blank.

Table = Vendor
Column = PhoneNumber

Basically: replace(PhoneNumber,'-','')

I just want to strip the - (dash) from the field.

What's the easiest way to do this?

SQL Server 2005.

Thanks,
Greg


From: Plamen Ratchev on
You posted the correct syntax:

SELECT REPLACE(PhoneNumber, '-', '') AS phone
FROM Vendor;

Or if you need to update:

UPDATE Vendor
SET PhoneNumber = REPLACE(PhoneNumber, '-', '')
WHERE PhoneNumber LIKE '%-%';

--
Plamen Ratchev
http://www.SQLStudio.com
From: Greg Berthume on
Perfect.

Thanks Plamen!

It's been one of those brain dead evenings. LOL

"Plamen Ratchev" <Plamen(a)SQLStudio.com> wrote in message
news:SYSdna08ULl5x-bWnZ2dnUVZ_jVi4p2d(a)speakeasy.net...
> You posted the correct syntax:
>
> SELECT REPLACE(PhoneNumber, '-', '') AS phone
> FROM Vendor;
>
> Or if you need to update:
>
> UPDATE Vendor
> SET PhoneNumber = REPLACE(PhoneNumber, '-', '')
> WHERE PhoneNumber LIKE '%-%';
>
> --
> Plamen Ratchev
> http://www.SQLStudio.com