format decimal to char

Posted on 2007-10-01
Last Modified: 2008-03-22
hi all,

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

CAST((  (FORMAT 'zzzzzzzzzzzzv')) AS CHAR(12)),CAST('|'  as char(1)),
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

Question by:rajeshnayakwadi
    LVL 19

    Expert Comment

    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
    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 Comment

    Hi Nick,
    can you please explain with an example how to preserve the sign ?
    LVL 19

    Accepted Solution

    depends if you want positive numbers to have a + sign, assuming you don't

    CAST((  (FORMAT '-zzzzzzzzzzzzv')) AS CHAR(12)),CAST('|'  as char(1)),
    customer b

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction If you are not already aware of what you could use a table with sequential integer values for in SQL, you can read Delimited String Parsing in SQL Server 2005 or later ( by BrandonGalderisi (h…
    This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now