Trouble with importing CSV into SQL Server using BULK IMPORT when the CSV has formatting errors

861 Views Asked by At

I am trying to import a .CSV file into my SQL Server database. This is the script I am using:

BULK INSERT <table_name>
FROM '/data.txt'
WITH
(
  FIRSTROW = 2,
  FORMAT='CSV',
  ERRORFILE = '/RowErrors.txt',
  MAXERRORS = 100
)

The trouble is my CSV has rows like the following in it.

"1-XY-YYYY","","","",""GXXXXX","SuXXXXXXXX","1-XY-YYYY"

Note the ""GXXXXX" in column 5.

The import stops with the following error when it gets to that row

Bulk load failed due to invalid column value in CSV data file

Is there some way to get the importer to ignore data formatting error like we can with the MAXERRORS property?

0

There are 0 best solutions below