If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Keeping leading zero when convert integer to char

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-08, 06:34
chulgyu100 chulgyu100 is offline
Registered User
 
Join Date: Nov 2008
Posts: 2
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.
Reply With Quote
  #2 (permalink)  
Old 11-19-08, 07:03
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
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.
Reply With Quote
  #3 (permalink)  
Old 11-19-08, 07:07
umayer umayer is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 11-19-08, 07:27
chulgyu100 chulgyu100 is offline
Registered User
 
Join Date: Nov 2008
Posts: 2
Thanks so much for reply.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On