Solved

Sql replace statement

Posted on 2014-02-06
3
295 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 66

Accepted Solution

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

Author Closing Comment

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

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

632 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