Solved

SQL update/change character query

Posted on 2009-07-11
3
297 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
  • 2
3 Comments
 
LVL 142

Accepted Solution

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

Open in new window

0
 
LVL 142

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

919 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