Friday, February 24, 2012

Bulk insert

My first try with Bulk insert has failed.

In MSDE 1.0 I have made a sp with the following command:
Bulk insert Rute2 From 'c:\Rute.txt' with (Fieldterminator=';', Keepnulls, Codepage='raw')

The error message is:
Bulk Insert: Unexpected end-of-file (EOF) encountered i data file.

The text file end with a: . If removed the insert succed.
But can I do without that will be nice.
How can I solve this problem?Ask the file provider to ommit the non printing character. If that is not an option, you might write a quick script to strip the last line of the file.

I don't know of a way to tell BCP or Bulk Insert how to deal with this record. Now if you can use DTS things look better.

I created the following table:
create table psy(f1 varchar(10),f2 varchar(10),f3 varchar(10))

I then created the following file:
ABC;;123
DEF;;456


I then selected the psy table in EM, selected All Tasks, Import Data, accepted all the defaults, and successfully imported the data.|||Did u set the bulkcopy option for the database?

sp_dboption 'databasename' 'select into/bulkcopy'

No comments:

Post a Comment