Hi All,
Can someone clue me in on BULK INSERT? I've used it to create a table of one column, and everything worked fine, but now I have a TXT file of about 11 fields. I've tried importing the data by using this as a comma-delimited CSV file, and I've tried the import by using it as a tab-delimited TXT file.
I keep getting several error messages (this one on using the tab-delimited TXT file):
Msg 4866, Level 16, State 1, Line 1
The bulk load failed. The column is too long in the data file for row 1, column 11. Verify that the field terminator and row terminator are specified correctly.
Msg 7399, Level 16, State 1, Line 1
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 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
All of the fields in my table can accept nulls. The table created fine. Here's my code:
USE im
CREATE TABLE Customer_Contacts
(
ContactName nvarchar(50),
CompanyName nvarchar(100),
Address1 nvarchar(255),
Address2 nvarchar(255),
Address3 nvarchar(255),
City nvarchar(32),
State nvarchar(32),
Zip nvarchar(32),
Country nvarchar(50),
Phone nvarchar(32),
Salesrep nvarchar(50)
)
BULK INSERT Customer_Contacts
FROM 'e:\temp\iv\customer_contacts.txt'
WITH
(
FIRSTROW = 1,
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n\r',
KEEPNULLS
)
I am NOT familiar with a FORMAT FILE, and I wasn't sure even if I needed one.
NOTE: Some of the data's missing in these fields, but that shouldn't be a problem,should it?
When I was using the comma-delimited file, there was a dangling comma at the end of the row. I tried deleting that, but still didn't work.
Any help is greatly appreciated.
How come seemingly straightforward commands behave with such contrariness in Microsoft? It's never like the tutorials.
If someone could also briefly outline the steps to using the BULK INSERT, please, I'd be grateful.
I thought all I need was a comma-delimited .TXT file, and the command.
Thanks in advance,
mickeyj2
Can someone clue me in on BULK INSERT? I've used it to create a table of one column, and everything worked fine, but now I have a TXT file of about 11 fields. I've tried importing the data by using this as a comma-delimited CSV file, and I've tried the import by using it as a tab-delimited TXT file.
I keep getting several error messages (this one on using the tab-delimited TXT file):
Msg 4866, Level 16, State 1, Line 1
The bulk load failed. The column is too long in the data file for row 1, column 11. Verify that the field terminator and row terminator are specified correctly.
Msg 7399, Level 16, State 1, Line 1
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 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
All of the fields in my table can accept nulls. The table created fine. Here's my code:
USE im
CREATE TABLE Customer_Contacts
(
ContactName nvarchar(50),
CompanyName nvarchar(100),
Address1 nvarchar(255),
Address2 nvarchar(255),
Address3 nvarchar(255),
City nvarchar(32),
State nvarchar(32),
Zip nvarchar(32),
Country nvarchar(50),
Phone nvarchar(32),
Salesrep nvarchar(50)
)
BULK INSERT Customer_Contacts
FROM 'e:\temp\iv\customer_contacts.txt'
WITH
(
FIRSTROW = 1,
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n\r',
KEEPNULLS
)
I am NOT familiar with a FORMAT FILE, and I wasn't sure even if I needed one.
NOTE: Some of the data's missing in these fields, but that shouldn't be a problem,should it?
When I was using the comma-delimited file, there was a dangling comma at the end of the row. I tried deleting that, but still didn't work.
Any help is greatly appreciated.
How come seemingly straightforward commands behave with such contrariness in Microsoft? It's never like the tutorials.
If someone could also briefly outline the steps to using the BULK INSERT, please, I'd be grateful.
I thought all I need was a comma-delimited .TXT file, and the command.
Thanks in advance,
mickeyj2