Solved

SQL Server 2005 Replace string

Posted on 2007-11-14
4
2,697 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
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
Comment Utility
update Properies
set CompleteDescription = replace(CompleteInstruction, '  ',' ' )
where active  = 1
0
 
LVL 142

Accepted Solution

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

Author Comment

by:lrbrister
Comment Utility
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
Comment Utility
both are exactly the same except in the  where part (Actually i missed the first condition, Angel's code is better  )
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now