Solved

SQL update/change character query

Posted on 2009-07-11
3
299 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 143

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 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

840 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