|
|
Archives of the TeradataForum
Message Posted: Wed, 11 Oct 2006 @ 16:39:43 GMT
Subj: | | Re: SQL Replace Function for text |
|
From: | | Bagare, Vinay |
Rao,
There are UDF available to do this. I have developed SQL which could help you in this.
SEL
NME
,POSITION('KUMAR' IN NME) AS START_POINT
,CHARACTER_LENGTH(TRIM(NME)) AS MAX_LEN
,CHARACTER_LENGTH('KUMAR') AS NO_CHAR
,CASE WHEN START_POINT > 1
THEN SUBSTRING(NME FROM 1 FOR (START_POINT-1)) || 'DBA'
|| SUBSTRING(NME FROM (START_POINT+NO_CHAR) FOR MAX_LEN)
WHEN START_POINT = 1
THEN 'DBA' || SUBSTRING(NME FROM 1 FOR NO_CHAR)
WHEN MAX_LEN = START_POINT + NO_CHAR
THEN SUBSTRING(NME FROM 1 FOR (START_POINT-1)) ||
'DBA' END AS T
FROM SYSDBA.TEST
Thanks,
Vinay Bagare
| |