I'm trying to import a correctly quoted CSV file, meaning data is only quoted if it contains a comma, e.g.:
41, Terminator, Black 42, "Monsters, Inc.", Blue
I observe that the first row imports correctly, but the second row errors in a manner that suggests the quoted comma was treated as a field separator.
I have seen suggestions such as this one
SQL Bulk import from CSV
to change the field terminator
FIELDTERMINATOR='","'
However, my CSV file only quotes fields that need it, so I do not believe that suggestion would work.
Can SQL Server's BULK IMPORT statement import a correctly quoted CSV file? How?
Unfortunately SQL Server interprets the quoted comma as a delimiter. This applies to both BCP and bulk insert .
From http://msdn.microsoft.com/en-us/library/ms191485%28v=sql.100%29.aspx
If a terminator character occurs within the data, it is interpreted as a terminator, not as data, and the data after that character is interpreted as belonging to the next field or record. Therefore, choose your terminators carefully to make sure that they never appear in your data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With