Link to home
Start Free TrialLog in
Avatar of nachtmsk
nachtmskFlag for United States of America

asked on

Sql replace statement

Hi,
I'm using SQL server 2005
I entered in a bunch of data but forgot to clean one of the fields before I did.
The field has some dashes in it   " - ".

I don't know how to remove the dash in each of the fields by using only SQL. I could do it with perl but I'm wondering how I would loop through all the records and replace the dash (-) with nothing.

So for arguments sake the field name is  address

Something like
 
Foreach record in table AddressList
    Get the value of the field 'address'
    Remove dash(es) if present
    end foreach

Thanks,
Nacht
Avatar of rawinnlnx9
rawinnlnx9
Flag of United States of America image

Use the REPLACE() function.

REPLACE ( string_expression , string_pattern , string_replacement )
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nachtmsk

ASKER

Thanks, that worked perfectly.