Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 08 Jan 2004 @ 11:52:06 GMT


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


Subj:   Re: How to remove 'spaces' in a telephone number field using Teradata SQL
 
From:   Dieter Noeth

Mike Grant wrote:

  I need to be able to get rid of 'spaces' in a telephone number field using Teradata SQL is there a function to allow this? The spaces could be in any position within the 11 character field? I've found the 'trim' function but this only removes trailing and leading blanks?  


  example before: 01234 56789 after 0123456789.  



Only one blank?

select
   case
     when position(' ' in phone) > 0
     then substring(phone from 1 for position(' ' in phone) -1)
       || substring(phone from position(' ' in phone)  + 1)
     else phone
   end

But this gets quite ugly, if there may be more than a single blank...


Dieter



     
  <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