Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 28 Jun 2006 @ 21:19:18 GMT


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


Subj:   Re: CAST into varchar 2 versions
 
From:   Michael Larkins

Hello Vivek:

It is because the second example you provide is not doing a CAST. You are asking Teradata to change the data type of the data. Although this is in essence what CAST does, CAST is a function written to explicitly return the converted data. It has intelligence coded into it to accomplish both the data conversion and the elimination of leading spaces (different than truncation). The second is not a function, it is a requestable conversion because you are asking Teradata to change the data type attribute. If you want it to trim also, you need to ask it to do so using the TRIM function.

Teradata did exactly what you asked it to do in both instances. Therefore, if you want it converted and trimmed, you should be using CAST. If you only want conversion, you can change the attribute. However, it is rather silly to use an new attribute to convert and a function (TRIM) to eliminate leading spaces when one function (CAST) does both. You only need to figure out ahead of time what you want in your answer set and make the appropriate request.


Regards,

Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor



     
  <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