I have read many articles and tried several methods but don't have any luck.
I am importing table A (whose cost is char to table B (which requires float).
What I tried:
--cast([Cost] as float)
-- cast(ISNULL([Cost],0) as float)
-- NULLIF(CAST(ISNULL([Cost],0) as float), 0)
convert(float,replace([Cost],',','') )[Cost]
Sample data
FINAL Freight Cost
1248
1248
193.79
201.56
1475.71
97.86
97.86
97.86
125.49
97.86
447.83
450
492.99
450
And I still get this error:
Error converting data type nvarchar to float
Update:
In addition, I am not sure how to modify the existing code based on the answers;
The existing code structure
1. creat table B
2. insert into B () select[DestAddress], [COST] from A
I also tried CAST(test AS FLOAT) AS CastedValue
Why float? The dataset will be sent to an optimization algorithm which requires float. Thanks for pointing it out though.