Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 31 Dec 2003 @ 20:20:08 GMT


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


Subj:   Re: Extracting characters from a string
 
From:   Akshay.Munshi

Here's my suggestion:

select SUBSTR('FDB$H$03121622FDBPKG1_ETL', 1,
INDEX('FDB$H$03121622FDBPKG1_ETL', '$')-1)

select SUBSTR(SUBSTR('FDB$H$03121622FDBPKG1_ETL',
INDEX('FDB$H$03121622FDBPKG1_ETL', '$')+1), 1,
INDEX(SUBSTR('FDB$H$03121622FDBPKG1_ETL',
INDEX('FDB$H$03121622FDBPKG1_ETL',
'$')+1), '$')-1)


This way, if you have more or less number of characters before each $, you get them all. The only requirment is that the input string should have atleast 2 '$' signs. See below - I modified input string to include additional characters.

select SUBSTR('FDDBB$GGH$03121622FDBPKG1_ETL', 1,
INDEX('FDDBB$GGH$03121622FDBPKG1_ETL', '$')-1)

select SUBSTR(SUBSTR('FDDBB$GGH$03121622FDBPKG1_ETL',
INDEX('FDDBB$GGH$03121622FDBPKG1_ETL', '$')+1), 1,
INDEX(SUBSTR('FDDBB$GGH$03121622FDBPKG1_ETL',
INDEX('FDDBB$GGH$03121622FDBPKG1_ETL', '$')+1), '$')-1)



     
  <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