Discussion:
Importing CSV File
(too old to reply)
Ripper
2008-12-12 22:24:01 UTC
Permalink
I am attempting to import a CSV file using the Bulk Insert sql command...

USE datasheets
BULK INSERT tblgrades
FROM '\\PHS-CI-TEST\c$\book1tab.txt'
WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n\r')
GO

The command goes, but then I hit an error.
Msg 4864, Level 16, State 1, Line 1
Bulk insert data conversion error (type mismatch) for row 1, column 2 (LocID).

The first column is the primary key. the second column, the first one in my
csv file, is a 6 digit number. On the table it is set to int. I can't
figure out why I am getting the error when the CSV is a number and the second
column, the first after the primary key, is set to int.

Anyone have any ideas?
--
Thanks As Always
Rip
Peter Gibbons
2008-12-12 22:44:53 UTC
Permalink
Post by Ripper
I am attempting to import a CSV file using the Bulk Insert sql command...
USE datasheets
BULK INSERT tblgrades
FROM '\\PHS-CI-TEST\c$\book1tab.txt'
WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n\r')
GO
The command goes, but then I hit an error.
Msg 4864, Level 16, State 1, Line 1
Bulk insert data conversion error (type mismatch) for row 1, column 2 (LocID).
The first column is the primary key. the second column, the first one in my
csv file, is a 6 digit number. On the table it is set to int. I can't
figure out why I am getting the error when the CSV is a number and the second
column, the first after the primary key, is set to int.
Anyone have any ideas?
Are you sure that the ROWTERMINATOR should not be \r\n?

Regards,

Peter

Loading...