0

I've got a table with 3 columns, ID, CourseID, CourseTitle. I have a CSV File that has CourseID and Course title in it. This is being inserted into table "Course." In this table I have ID set to 'isEntity' so it auto generates. How do I go about inserting the data into the table and ignoring the ID column? Right now I'm getting an error saying

"Bulk load data conversion error(type mismatch or invalid character for specified codepage) row1 column 2 (ID).

BULK INSERT Course
FROM 'E:\CourseCSV.csv'
WITH
(
FIRSTROW = 1,
FIELDTERMINATOR = ',',  --CSV field delimiter
ROWTERMINATOR = '\n',   --Use to shift the control to next row
TABLOCK
)
user3487671
  • 109
  • 1
  • 9
  • related: http://stackoverflow.com/questions/2139069/how-to-skip-columns-in-csv-file-when-importing-into-mysql-table-using-load-data – billynoah Aug 12 '16 at 03:53

2 Answers2

0

Try adding an ID column to your CSV file, but leave it blank.

SilicaGel
  • 469
  • 3
  • 11
0

There are many ways.

1 - create a table without auto_increment id and import csv into this table, and use SQL to insert into Course eg

CREATE TABLE tmp (CourseID int, CourseTitle varchar(255))

And import csv into tmp table

INSERT INTO Course(CourseID, CourseTitle)
SELECT * FROM tmp

2 - You can use http://topnew.net/sidu to import csv directly into Course table, when you do import, delete ID from field list at import window:

enter image description here

SIDU
  • 2,168
  • 1
  • 10
  • 19
  • No luck I'm doing all this DB work right within Visual Studio 2015. I built a local DB in VS so i'm using i think...T-SQL and a lot of the popular statements have quirks to them – user3487671 Aug 12 '16 at 15:24