VARCHAR to DECIMAL

前端 未结 12 655
清歌不尽
清歌不尽 2020-12-06 09:24

I want to convert a varchar(max) column to decimal(10,4).

When I try to use cast or convert I am getting an arit

12条回答
  •  Happy的楠姐
    2020-12-06 09:47

    You are missing the fact that 6.999,50 is not a valid decimal. You can't have a comma and a decimal point in a decimal value surely? What number is it supposed to be?

    Assuming your locale specifies . as grouping and , as decimal separator: To remove the grouping digits:

    SELECT CONVERT(decimal(11,2), REPLACE('6.999,50', '.', ''))

    will yield 6999,50 as a decimal

提交回复
热议问题