We help IT Professionals succeed at work.

format decimal to char

rajeshnayakwadi
on
25,097 Views
Last Modified: 2008-03-22
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

Comment
Watch Question

Nick UpsonPrincipal Operations Engineer
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
Hi Nick,
can you please explain with an example how to preserve the sign ?
Principal Operations Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.