Home Page for the TeradataForum
 
https:

Archives of the TeradataForum

Message Posted: Wed, 12 Jun 2002 @ 10:48:11 GMT


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


Subj:   Re: Casting to char
 
From:   Dieter Nöth

This is already working:

if you use substring on an integer there's already an automatic typecast. It's casted using the column's format, i.e. with default format '-(10)9' 123456 will become right aligned ' 123456'

If you use CAST, it will be left aligned '123456'

select substring(123456 from 1 for 4);

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

Substring(123456 From 1 For 4)
------------------------------

select substring(cast(123456 as char(11)) from 1 for 4);

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

Substring(123456 From 1 For 4)
------------------------------
1234

The next one is a smallint with a format '-(5)9'
select substring(12345 from 1 for 4);

Substring(12345 From 1 For 4)
-----------------------------
 123

select substring((12345 (format '999999')) from 1 for 4);

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

Substring(12345 From 1 For 4)
-----------------------------
0123

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: 28 Jun 2020