Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 14 Nov 2001 @ 20:23:49 GMT


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


Subj:   Need help on sql syntax to convert values from decimal to characters
 
From:   faisal

Hi all,

I'm doing some work with Teradata and I don't know a lot about the sql syntax, perhaps you guys could help me out.

1. create table TABLESOURCE with one column ID in DECIMAL(18,0)

2. create table TABLETARGET with one column ID in CHARACTER(255)

3. insert some values in TABLE_SOURCE like 7519,0,-1,13

4. I want to transfer these values from TABLESOURCE to TABLE_TARGET and I use this sql statement:

insert into TABLETARGET (ID) select trim(leading ('0') from ID(format'9(18)')(char(255))) from TABLESOURCE

The syntax trim(leading ('0') from ...) is to truncate all zeros on the left side of the value. Apparently the values 7519 and 13 have been converted correctly but 0 and -1 become ' ' (nothing) and 1

Does anybody know other sql statement to get all values correctly?.

thank you in advance

faisal



     
  <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