1

when i do

select cast('2,2' as float)
replace('2,2' , ',' , '.' ) is needed before casting

i have the following error " Error converting data type varchar to float." because there is the comma.

when i do

 select cast('2.2' as float)

the result is "2,2" with a comma

i am a bit lost with that since i integrate excel files with french formatted numbers: commas "," instead of "." so i have tons of theses errors

thankss!

Badr Erraji
  • 141
  • 1
  • 11

3 Answers3

0

SQL Server Documentation states that the notation needed to be used for casting numeric/float characters to numeric format is Scientific Notation

Numbers are displayed with 6,720,000,000 => 6.72×109 in Scientific Notation

Thus the answer is : Regardless of Regional Settings input format is always fixed to Scientific Notation

Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72
0

this should work

declare @rate double
set @rate = 1.954
select     FORMAT(@Rate, 'G', 'fr-fr') as formatted_decimal

1,9540

will print

DDS
  • 2,340
  • 16
  • 34
-1

please use this i think this will help you

select cast(replace('2,2',',','.') as float)
Mohammad Shehroz
  • 226
  • 2
  • 11