?
Solved

SQL update/change character query

Posted on 2009-07-11
3
Medium Priority
?
303 Views
Last Modified: 2012-05-07
Hi,

I have an MSSQL database with a table with a 4000 character field. The fields contain random text, some includes '&' characters and because they're used for the web I'd like to change them to '&'.

So the query I'd like is to search for all instances of '&' within the string and change them to '&'
0
Comment
Question by:joshgeake
[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
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 total points
ID: 24830117
you mean:
UPDATE yourtable SET yourfield = REPLACE('&', '&') WHERE yourfield LIKE '%&%'

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24830119
>and because they're used for the web I'd like to change them to '&'.
actually, you should not do that.
instead, you should eventually use html_encode functions to get the text "encoded"...
0
 
LVL 14

Expert Comment

by:shru_0409
ID: 24830192
update yourtable  set yourcolumn = replace (yourcolumn, '&', '&') where yourcolumn  like '%&%';
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

770 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