Replacing Characters in a table column

Discussion in 'Databases' started by Domen Lombergar, Jun 10, 2007.

  1. #1
    Hey. I've recently noticed that some of the letters didn't quite translate well into the database when imported.

    Basically characters like –’ came out really silly.

    Does anyone know of a sql call to filter these out and replace them with normal versions (-')?

    Thanks.
     
    Domen Lombergar, Jun 10, 2007 IP
  2. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #2
    characters like this?

    â€Â
     
    sawz, Jun 10, 2007 IP
  3. Domen Lombergar

    Domen Lombergar Peon

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Currently I'm having major problems with the following four:

    –
    ’
    “
    ”

    The database entries for these chars result in a vertical rectangle and a space.
     
    Domen Lombergar, Jun 10, 2007 IP
  4. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #4
    i had character problems when i moved a forum database. the message table was loaded up with different strings similiar to this: … they replaced the punctuation code.

    ! got changed to …â€Â

    , got changed to …

    etc, was weird

    so i identified which string represented which punctuation mark and replaced them. i had to export that table and manually make the changes, around 30,000 of em, took an hour or so.
     
    sawz, Jun 10, 2007 IP
  5. Domen Lombergar

    Domen Lombergar Peon

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Manual replacements, huh? Hehe.

    Isn't there any automated way to do this?
     
    Domen Lombergar, Jun 12, 2007 IP
  6. jamix

    jamix Peon

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Well, you can use the replace() function:

    update my_table set my_field=replace(my_field, 'old_text', 'new_text');

    You'll have to repeat that for each bad character, but since there's only four, it's doable (run the query four times).
     
    jamix, Jun 13, 2007 IP
    sawz likes this.
  7. glasglow

    glasglow Active Member

    Messages:
    926
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #7
    I use this function all the time.. It's the best "find and replace" function that I can find too.
     
    glasglow, Jun 14, 2007 IP