Importing data to Sybase, getting "EOF encountered" error

When I try to import this file (1 record):
0261309333170084904400##7#4#34342036       ^84904400##7#4#34342^213027967000002    ^036^026130933317000  }  

Open in new window


I get this error:
executing... /stars/UTIL/bcpin stars1 dent_temp dent_fix.dat
Tue Oct 15 11:10:09 EDT 2013
Password: 

Starting copy...
Unexpected EOF encountered in BCP data-file.
bcp copy in failed
Tue Oct 15 11:10:09 EDT 2013

Open in new window


The file is generated from a Sql statement on another Unix box and I append "}" to each row in the sql query.

But when I create the file manually with 1 record, it inserts ok . . . So I copy the same data into a blank file without the trailing  }, then simply type in the }, and this loads ok !
executing... /stars/UTIL/bcpin stars1 dent_temp dent_fix_test.dat
Tue Oct 15 11:09:51 EDT 2013
Password: 

Starting copy...
1 rows copied
Tue Oct 15 11:09:51 EDT 2013

Open in new window


What's going on with this ?

I have another process where I take a flat file and append "}" to the end of each record (via SSIS), so apparently Sybase wants this, but why won't it take my file that I create with } at the end ?

I'm pretty sure I don't need any crazy commands, since the command to load my other process is simply
bcpin2_tilde stars1 CBAS_PROV_IDS CBAS_ID.dat

Plus my command where I successfully imported the one record was
bcpin my_db my_table _my_file.dat
LVL 1
Alaska CowboyAsked:
Who is Participating?
 
virtuadeptCommented:
This is probably happening because Unix uses a linefeed only for text file line termination and Windows uses carriage return + linefeed.  When converting files to and from Unix on a Sybase SQL server project I worked on previously, we had to strip CR when heading to the Unix world, and add them back in when coming from the Unix world.  We were using a Unix style scripting tools kit called MKTools or something like that which had a TR command to "translate" and we would just TR the file to either strip CR out or change LF to CR-LF depending on which way we went. You may need some kind of file utility to do this. Writing something to do this in VB or C# would be pretty trivial. Or there are a number of shareware file utilities that have this and many more features, like swiss file knife (SFK).
0
 
Alaska CowboyAuthor Commented:
virtuadept, thank you, good info. At least I'm not alone in wrestling with this.

in the meantime, I was able to take my output, run it through SSIS, and add " } " to the end of the record, and then it loaded !

but good info, thanks.
0
 
Alaska CowboyAuthor Commented:
good explanation by virtuadept. I used my workaround as explained above as brute force method and I got my data loaded to Sybase.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.