Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2008
    Posts
    2

    Unanswered: Keeping leading zero when convert integer to char

    Hello,

    i want to keep leading zero when converting integer to char.
    for example, integer 6 is converted '00006'.

    any comment will be appreciated.

  2. #2
    Join Date
    Oct 2004
    Location
    DELHI INDIA
    Posts
    338
    There must be other easier ways to do the same. You can try this as well:

    select rtrim(char(decimal(col1,6))) from test.xxx2 with ur

    Where COL1 is of data-type INTEGER.

  3. #3
    Join Date
    Dec 2005
    Posts
    273
    TRY:

    DIGITS( value )


    eg: DIGITS ( 6 ) returns '0000000006' , if 6 is an INTEGER
    and it returns '00006' if 6 is a SMALLINT

  4. #4
    Join Date
    Nov 2008
    Posts
    2
    Thanks so much for reply.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •