SQL Server: Error converting data type nvarchar to numeric

前端 未结 3 677
时光说笑
时光说笑 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:41

    I was running into this error while converting from nvarchar to float.
    What I had to do was to use the LEFT function on the nvarchar field.

    Example: Left(Field,4)

    Basically, the query will look like:

    Select convert(float,left(Field,4)) from TABLE
    

    Just ridiculous that SQL would complicate it to this extent, while with C# it's a breeze!
    Hope it helps someone out there.

提交回复
热议问题