• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

SQL update/change character query


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 '&'
  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you mean:
UPDATE yourtable SET yourfield = REPLACE('&', '&') WHERE yourfield LIKE '%&%'

Open in new window

Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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"...
update yourtable  set yourcolumn = replace (yourcolumn, '&', '&') where yourcolumn  like '%&%';
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now