sql-servercsv-import

Commas within CSV Data


I have a CSV file which I am directly importing to a SQL server table. In the CSV file each column is separated by a comma. But my problem is that I have a column "address", and the data in this column contains commas. So what is happening is that some of the data of the address column is going to the other columns will importing to SQL server.

What should I do?


Solution

  • If there is a comma in a column then that column should be surrounded by a single quote or double quote. Then if inside that column there is a single or double quote it should have an escape charter before it, usually a \

    Example format of CSV

    ID - address - name
    1, "Some Address, Some Street, 10452", 'David O\'Brian'