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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display fields of float type without e-xxx 1

Status
Not open for further replies.

swreng

MIS
Jun 22, 2006
90
GR
Dear all,

I have in my database some float fields which they contain data like this:

a) 0,000000000025
b) 0,000036

if i make a simple select statement then i will have a result like this:

a) 5000000000000001E-11
b) 6000000000000001E-5

Is it possible to avoid the above format and display it as it is saved in the table?

I am using SQL SERVER 2000

Many thanks




 
You should understand that the way the data is stored is different than the way the data is displayed. My best suggestion to you is to do your data formatting in the front end application.

For example, if you are showing the data in vb, c#, java, asp, php, etc... do your formatting there.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
don't use floats, never ever!
Anyway you can convert to decimal
run this

Code:
declare @b float
select @b =0.000000000025

select @b, convert(decimal(30,20),@b)


output
Code:
2.5000000000000001E-11	.00000000002500000000

yes I used dots not commas, you probably need to change the . to a , since you live in Southern Europe

Denis The SQL Menace
--------------------
SQL Server Code,Tips and Tricks, Performance Tuning
Google Interview Questions





 
To add to what Dennis said, floats are an approximate data type. If you do any calculations whatsoever with this data you will get rounding errors. Your best bet is to change the data to a decimal datatype. Floats should never be used.

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top