Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting double to varchar 1

Status
Not open for further replies.

mikeparas

Programmer
Jun 24, 2003
4
AU
Hi, im having some problem when im converting a double to varchar or char. Example I have a value of 128.28 then when i convert it to varchar, im getting a "1.28384E2". Is there a way to convert a normal number to a varchar in its normal form. Thank you and hoping for your replies.
 
Try converting into BigInt then convert this bigInt into varchar.

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
s.sipahi@sahinlerholding.com.tr
 
Hi,

when i try to convert it to big int, it removes the decimal places. any other ideas?
 
Hello Mike,

How about this one:

Select
CASE
WHEN SUBSTR(CHAR(XXX),1,7) = '0000000' THEN REPLACE(CHAR(XXX),'0000000','')
WHEN SUBSTR(CHAR(XXX),1,6) = '000000' THEN REPLACE(CHAR(XXX),'000000','')
WHEN SUBSTR(CHAR(XXX),1,5) = '00000' THEN REPLACE(CHAR(XXX),'00000','')
.........................................................
.........................................................
ELSE 'NOT_CONVERTED'
END AS CONVERTED
from TABLE

Add WHEN lines for bigger values, the output should be VARCHAR.
For negative values you shall have to extend the logic....

T. Blom
Information analyst
tbl@shimano-eu.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top