Archives of the TeradataForum
Message Posted: Fri, 23 Feb 2007 @ 10:09:52 GMT
Subj: | | Re: Replacing a character |
|
From: | | Mohd Suhail |
Hi,
The following code works absolutely fine for replaceing '-' with '_'. However u can only replace the first '-' with '_' with this piece of
code.
To do it repeatedly u can form a procedure and call it recursively.
select TRIM (
CASE POSITION('-' IN 'T-RAT')
WHEN
0
THEN
'T-RAT'
ELSE
SUBSTRING('T-RAT' FROM 1 FOR INDEX('T-RAT','-') - 1) || '_' ||
SUBSTRING('T-RAT' FROM (INDEX('T-RAT','-')+1) FOR characters('T-RAT'))
END
)
Output:
T_RAT
Hope i answered your question.
|