Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 17 Jul 2002 @ 16:48:50 GMT


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


Subj:   Re: Teradata String Replace within a string Function
 
From:   Michael Larkins

Hi:

If the "-" is in different locations thru-out the data, you might try the following:

upd custtable
set custfield = Substring (custfield from 1 for index(custfield,'-')-1)
|| '_' || substring (custfield from index(custfield,'-')+1 ) ;

This is the simple SQL approach. However, you must run this once per '-' that occurs in the data. In other words, for acct-chg-it, you must run this twice and it changes one '-' to '_' per run.

Now, this can be done in one run, but the second substring must be a substring starting from the index value that points after the second '-'. I did not have time to sit down and test the more elaborate approach. If you wish to contact me directly, so that I know who you are, we can discuss the more elaborate approach.


Regards,

Mike



     
  <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