Scientfic Notation problem

  • I am having a problem with cast or convert displaying a float value cast or converted to varchar coming across as a number in scientific notation. I need the result to not be in scientific notation. Any Ideas?

  • Where are you getting the float from?.

    Is it from a table, or an external source

  • When converting directly from float to a string, you can only control the number of decimal places used with scientific notation if there are more than six digits. Cast the value as dec, and then convert that to a string, e.g.:

    
    
    DECLARE @f float
    SET @f = 123456789.0123456
    SELECT CAST(@f AS varchar(20)) -- returns 1.23457e+008
    SELECT CONVERT(varchar(22),@f,2) -- returns 1.234567890123456e+008
    SELECT CAST(CAST(@f AS dec(16,7)) AS varchar(20)) -- returns 123456789.0123456

    --Jonathan



    --Jonathan

  • DavidT: The float was in a table.

    Jonathan: Thanks that did it. I was on that poath but just wanted to ensure that I wasn't missing anything. Thx

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

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