Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 11 Oct 2006 @ 16:39:43 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


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



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023