Replacing Special Characters in Teradata

12,403

If you have Teradata 14 (and sorry, I don't), you should be able to use the new REGEXP_REPLACE function, something like this:

SELECT  'aa€bb' as source_col
       , REGEXP_REPLACE(source_col, '€') as new_col1
       , REGEXP_REPLACE(source_col, '€', NULL, 1, 0, 'c') as new_col2

The first example should do the trick; the second just shows the other function parameter values and their defaults. The third parameter is the replacement string, so when null, it should remove that character.

Share:
12,403
Adam
Author by

Adam

Updated on July 21, 2022

Comments

  • Adam
    Adam almost 2 years

    I have special character in Teradata database, and I want to remove it.

    Example - special character: "aa€bb"  (special charcter is "€" sign)
    Desired output: "aabb"
    

    How can I do that?

    • Rob Paller
      Rob Paller about 11 years
      Is it always that value or can it be anything that is not considered alphanumeric in the Latin character set? I'm thinking a UDF would be your best bet.