January 29, 2012 at 12:44 pm
Hi
I am trying to copy a data from text file to temp table using bulk insert but it gives me Error.
My text file contain data like
123233,123433
123333,434344
122333,234343
232333,233434
and i store this text file to C:\Users\mypc\Desktop\test.txt
in sql server management studio i ran this query
create table #PersonalData
(Addressid varchar(50),
Name varchar(50)
)
go
USE tempdb;
GO
BULK INSERT #PersonalData
FROM 'C:\Users\Unnati\Desktop\test.txt'
WITH (
FIELDTERMINATOR = ',',
rowterminator ='',
KEEPNULLS
);
GO
but it gave me Below Error Message
Msg 4863, Level 16, State 1, Line 1
Bulk load data conversion error (truncation) for row 2, column 1 (Addressid).
Msg 4863, Level 16, State 1, Line 1
Bulk load data conversion error (truncation) for row 3, column 1 (Addressid).
Msg 4832, Level 16, State 1, Line 1
Bulk load: An unexpected end of file was encountered in the data file.
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)".
Please Help me what i have to do to load the data from text file.
i appreciate for any help
Thank you.
January 29, 2012 at 1:30 pm
I think the problem is with the line that specifies the rowterminator. After I duplicated the error you got, I simply removed the rowterminator specification. The BULK INSERT then used the default row terminator of a newline '\r', and worked fine.
Here's the documentation for BULK INSERT
msdn.microsoft.com/en-us/library/ms188365.aspx
February 3, 2012 at 12:28 pm
Thank you very much..
i got my answer
February 5, 2012 at 1:44 pm
unnati.patel513 (2/3/2012)
Thank you very much..i got my answer
Ok... so what was the answer? Two way street here. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply