Solved

Sql replace statement

Posted on 2014-02-06
3
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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