nachtmsk
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, that worked perfectly.
REPLACE ( string_expression , string_pattern , string_replacement )