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

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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