I have a large .CSV
file, I tried to import it into SQL Server using Bulk Insert. A few records inserted correctly, however others are just messed up due to below reason.
Create table Testing
(
field1 varchar(10),
field2 varchar(10),
field3 varchar(10),
field4 varchar(50),
field5 varchar(10)
)
File data
no,fname,lname,address,cellphone
1,john,demo,10th street,1234567890
2,smith,demo,park view,111111111
3,venus,demo,"POBOX,CA",222222222
Code:
BULK INSERT npidata
FROM 'C:\temp.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
First two records inserted correctly, issue with 3rd record as more than 4 commas are into 3rd row.
Please suggest how to handle this case.
Thanks in advance.