Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL update/change character query

Posted on 2009-07-11
3
Medium Priority
?
304 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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