Assuming your language is set correctly to allow for comma for decimal you can do this:
TRY_CONVERT(float, TRY_CONVERT(money,@floatstr,1))
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I'm questionning about the most simple way to cast str like "1.456,05" where the dot is a thousand separator and the coma a decimal separator.
I have a Logic app Flow who call a cognitive service + send back a JSON + parse JSON + SQL server insert row (V2).
I cannot find a solution to resolve the cast problem for number who are up to 999 because of the dot .
I tried to do replace(".","") AND convert to float() at the same time in the Insert row forms but i cannot save my Logic app when i do it in that way.
The data must be send in a database to make further mathematics operation .
In all the method i used, i always have error like "cannot cast string to float"
Does anyone had to face this problem?
Assuming your language is set correctly to allow for comma for decimal you can do this:
TRY_CONVERT(float, TRY_CONVERT(money,@floatstr,1))
If comma is the decimal separator, then the next example seems to work:
declare @string as varchar(max) = '1.456,05'
select cast( replace(replace(@string, '.', ''), ',', '.') as float)
You can use this cast in your insert.