ms-accesscsv-import

Converting number to text with Access SQL


I have an *.csv file with data. I'm trying to transfer the data to an Access db.

My data look like this

enter image description here

I'm using an sql "INSERT INTO ... SELECT ... FROM" The construction itself works ok for Access.

The problem comes when I'm trying to convert a value like "99.48%" to a number 99.48 I use REPLACE([Featured Offer (Buy Box) Percentage],'%','') and this returns 99.48, but I get a warning - "data type mismatch" if a destination field has a numerical type. When I change field data type to text then it's ok. But I need numerical, finally like 0.9948

CDbl(REPLACE([Featured Offer (Buy Box) Percentage],'%','')) doesn't works - same warning "data type mismatch"

I will appreciate any help


Solution

  • CSV imports are notorious for localization issues. If the csv has . as decimal separator, but your Access/Windows locale expects ,, it cannot be imported as number.

    Your best bet is probably to define an import specification where you can specify the decimal separator . and field separator ,.