• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2720
  • Last Modified:

SQL Server 2005 Replace string

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'
  • 2
1 Solution
Aneesh RetnakaranDatabase AdministratorCommented:
update Properies
set CompleteDescription = replace(CompleteInstruction, '  ',' ' )
where active  = 1
Guy Hengel [angelIII / a3]Billing EngineerCommented:
update properties
  set completeDescription  = replace(completeDescription , '  ', ' ')
where completeDescription like '%  %'
 and active = '1'
lrbristerAuthor Commented:
aneeshattingal: and angelII...
  I trust both you guys...which one is better from a data safety perspective?
Aneesh RetnakaranDatabase AdministratorCommented:
both are exactly the same except in the  where part (Actually i missed the first condition, Angel's code is better  )
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now