SQL Server: Error converting data type nvarchar to numeric

前端 未结 3 678
时光说笑
时光说笑 2020-12-29 10:05

If I run the SQL query below; I get the following error:

Error converting data type nvarchar to numeric.

COLUMNA c

3条回答
  •  独厮守ぢ
    2020-12-29 10:49

    In case of float values with characters 'e' '+' it errors out if we try to convert in decimal. ('2.81104e+006'). It still pass ISNUMERIC test.

    SELECT ISNUMERIC('2.81104e+006') 
    

    returns 1.

    SELECT convert(decimal(15,2), '2.81104e+006') 
    

    returns

    error: Error converting data type varchar to numeric.

    And

    SELECT try_convert(decimal(15,2), '2.81104e+006') 
    

    returns NULL.

    SELECT convert(float, '2.81104e+006') 
    

    returns the correct value 2811040.

提交回复
热议问题