• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 24892
  • Last Modified:

format decimal to char

hi all,

i am using  the below query to do a fast export in teradata

sel
CAST((b.id  (FORMAT 'zzzzzzzzzzzzv')) AS CHAR(12)),CAST('|'  as char(1)),
from
customer b

here the column id in table has both negative and postive values but the above sql changes all negative numbers to postive. can anyone suggest me how to retain the negative number when i do select ?
sample customer table data
-7045
5678

0
rajeshnayakwadi
Asked:
rajeshnayakwadi
  • 2
1 Solution
 
Nick UpsonPrincipal Operations EngineerCommented:
Sign characters.
May be placed at the beginning or end of a format string. One sign
character places the edit character in a fixed position for the output
string.
If two or more of these characters are present on the left, the sign floats
(moves to the position just to the left of the number as determined by the
stated structure).
The + translates to + or - as appropriate; the - translates to - or blank.
0
 
rajeshnayakwadiAuthor Commented:
Hi Nick,
can you please explain with an example how to preserve the sign ?
0
 
Nick UpsonPrincipal Operations EngineerCommented:
depends if you want positive numbers to have a + sign, assuming you don't

sel
CAST((b.id  (FORMAT '-zzzzzzzzzzzzv')) AS CHAR(12)),CAST('|'  as char(1)),
from
customer b
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now