formatting data of float type

  • I need to show the data only 2 digits after the decimal point. but when I use select statement, a few have too many digits more than I want. for example, instead of showing 0.6, it appears as

    0.59999999999999998

    When I look at the data in enterprise manager, it is 0.6

    I tried round(num,2) but it did not make any difference.

    What can I do to get it right?

    Thanks

  • Format the data in your front-end. If you're just trying to make it look pretty in QA, you could use the STR() function or CAST is as a decimal, e.g.:

    SELECT STR(MyFloatCol,10,2), CAST(MyFloatCol AS dec(10,2))

    Why are you using float data type? That's a very rare data type to need in SQL Server...

    --Jonathan



    --Jonathan

  • Thanks Jonathan.

    I changed the data type to decimal and it works fine.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply