|
|
Archives of the TeradataForum
Message Posted: Wed, 29 Mar 2006 @ 12:36:39 GMT
Subj: | | Re: Cast Operator |
|
From: | | Michael Larkins |
Hi Sidharth:
They work different because cast is a funtion. It's job is to convert data from one type to another. Using (char(10)) after the column name
is asking Teradata to change the data type attribute for numeric to character, and it does. First, it lines up the data in memory, assigns the
character length as its maximum possible length and then returns the character length THAT YOU ASK FOR. You asked for the wrong length. An
integer column can have 10 digits plue a sign. You should have used (CHAR(11)) and really, you should have used the same length to be safe in
CAST.
Hope this helps and reminds you that if you are going to use short-cuts, do so carefully.
Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor
| |