Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Float value problem

Author  Topic 

ashtureav
Starting Member

2 Posts

Posted - 2011-08-24 : 09:27:51
I'm working with java and MS SQL

I have one column Exchange_Rate with Float datatype and value "0.00043"
when i try to fetch same value it gives me "4.3E-4" this value.
but i want that value in same format in which I have Inserted.

please do it needfully...

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-08-24 : 10:07:41
You DO get the same value as stored in the database.
Learn to separate the visualization of data and storage of data.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

radjiv1
Starting Member

3 Posts

Posted - 2011-08-24 : 12:07:00
You can format float column inside SELECT-query as follows:

SELECT CAST(Exchange_Rate AS NUMERIC(15,5)) FROM <table name>

Radjiv
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-08-24 : 13:10:49
quote:
Originally posted by radjiv1

You can format float column inside SELECT-query as follows:

SELECT CAST(Exchange_Rate AS NUMERIC(15,5)) FROM <table name>

Radjiv

That might work, but the OP should be aware that FLOATs and NUMERICs have different converstion rules when manipulating them. So, you may not get the same results.
Go to Top of Page

ashtureav
Starting Member

2 Posts

Posted - 2011-08-25 : 03:57:05
Thank you guys it works with cast as numeric in my scenario...
Go to Top of Page
   

- Advertisement -