Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Posts
    2

    Unanswered: Replacing a single character

    I have fields that have a bunch of characters I want to replace. How would I do that with an SQL statement. I could do this PERL but I wanted to hold off to see if I could do it directly in SQL first.

    The Characters are:
    CHR(12) with space
    ^ with '
    CHR(145) with '
    CHR(146) with '
    etc.....

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by djlerman
    I have fields that have a bunch of characters I want to replace. How would I do that with an SQL statement. I could do this PERL but I wanted to hold off to see if I could do it directly in SQL first.

    The Characters are:
    CHR(12) with space
    ^ with '
    CHR(145) with '
    CHR(146) with '
    etc.....
    Use Perl! A simple tr/// is much easier than the shenanigans you'll have to perform to simulate it using SQL!

    -PatP

  3. #3
    Join Date
    Dec 2003
    Location
    Houston, TX
    Posts
    21
    You declared "shenanigans" eheheh
    I do not fear computers. I fear the lack of them.
    -Isaac Asimov (1920 - 1992)

  4. #4
    Join Date
    Jun 2004
    Posts
    2
    O.K I figured it out (with the help of blogbarter.com). For any others out there that may need it. Here is the SQL statement to replace a single character:

    Code:
    update tablename set field = replace(field,'search','replace');
    or for ASCII Code:

    Code:
    update tablename set field = replace(field,char(012),char(032));
    Here is the link:
    http://analogduck.com/blog/modules/n...hp?storyid=179
    Last edited by djlerman; 06-15-04 at 13:22.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •