Reputation: 2309
Lets say I have this text file:
Name, Zipcode
Person1 2630
Person2, 2500
Person3, NA
I want to import everything as text. So i create a table:
DROP TABLE IF EXISTS ImportFromText;
CREATE TABLE ImportFromText ([Name] nvarchar(50),
Zipcode nvarchar(50));
Go
And then I try this:
BULK INSERT ImportFromText
FROM 'C:\Users\david\Desktop\Zipcode.txt'
WITH ( FORMAT='CSV',
ROWTERMINATOR = '\n'
);
Go
But I get this error:
Msg 4879, Level 16, State 1, Line 15
Bulk load failed due to invalid column value in CSV data file C:\Users\david\Desktop\Zipcode.txt in row 2, column 1.
Msg 7399, Level 16, State 1, Line 15
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 15
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
Upvotes: 0
Views: 146
Reputation: 3744
The only issue is with the delimiter in the second row (missing column separator).
The code works fine after correcting that.
Upvotes: 2