Solved

Sql replace statement

Posted on 2014-02-06
3
277 Views
Last Modified: 2014-02-06
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
0
Comment
Question by:nachtmsk
3 Comments
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 39839280
Use the REPLACE() function.

REPLACE ( string_expression , string_pattern , string_replacement )
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 39839297
UPDATE YourTable
SET YourColumn = REPLACE(YourColumn, '-', '')
0
 

Author Closing Comment

by:nachtmsk
ID: 39839475
Thanks, that worked perfectly.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now