Solved

SQL Server 2005 Replace string

Posted on 2007-11-14
4
2,706 Views
Last Modified: 2008-02-01
I have a table col carrying a lot of text in each rrecord.

I have a query that identifies the things that are causing export problems (Like | or double spaces..etc)

How can I update the records to rreplace the data double spaces with one space?

select mls, completeDescription from properties where completeDescription like '%' + '  ' + '%' and active = '1'
0
Comment
Question by:lrbrister
[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
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20280588
update Properies
set CompleteDescription = replace(CompleteInstruction, '  ',' ' )
where active  = 1
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20280630
update properties
  set completeDescription  = replace(completeDescription , '  ', ' ')
where completeDescription like '%  %'
 and active = '1'
0
 

Author Comment

by:lrbrister
ID: 20280974
aneeshattingal: and angelII...
  I trust both you guys...which one is better from a data safety perspective?
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20281022
both are exactly the same except in the  where part (Actually i missed the first condition, Angel's code is better  )
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

737 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