Basic Data conversion doubt

  • SELECT CONVERT(NUMERIC(28, 2), 2.5608655E7)

    --works okay

    SELECT CONVERT(NUMERIC(28, 2), '2.5608655E7')

    --throws error

    How to convert the varchar value ins table to 25608655.00

    DECLARE @MyTable TABLE

    (

    NumVal VARCHAR(25)

    )

    INSERT @MyTable

    SELECT '2.5608655E7'

    -- now I need a value 25608655.00 in the results without the error

    /*

    Server: Msg 8114, Level 16, State 5, Line 11

    Error converting data type varchar to numeric.

    */

    SELECT CONVERT(NUMERIC(28, 2), NumVal) FROM @MyTable

    Regards,
    gova

  • SELECT CONVERT(NUMERIC(28, 2), CONVERT(FLOAT, '2.5608655E7'))

    _____________
    Code for TallyGenerator

  • Thanks Sergy.

    I was trying all data types and just found Real and float works.

    Regards,
    gova

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

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