sql - bcp throwing unexpected EOF error unless the file has an extra \n -


i'm importing tab delimited text file sql server 2012 via bcp. it's working except final line of file, not imported. not usual unexpected eof issue delimiters set incorrectly or comma exists in data using comma delimiter. field delimiter explicitly set \t , row delimiter explicitly set \n. on checking final line in notepad ++ correctly contains data , tab characters. not, however, have end-of-line delimiter. instead file stops final tab character (the last field of row null). best of knowledge normal.

the weird part if add end-of-line delimiter end of file final line imports correctly. unusual thing final line data first field contains backtick before actual character data. backticks aren't used delimiters seems unlikely problem, line import when add "extra" end-of-line delimiter.

so, delimited text file supposed have end-of-line delimiter @ end of data? or else going on here?

anonymized bcp code:

bcp databasename.dbo.tablename in "l:\directoryname\filename.txt" -c  -s servername -u username -p passwordtext -f 2 -t \t -r \n 

as @tt noted, have sussed problem. 1 fix use powershell ensure there closing cr/lf on file:

powershell "get-content -path .\original.tsv | set-content -path .\corrected.tsv;" 

if there one, still there , no new 1 added. if missing, added.

then modify bcp line use corrected filename input, , clean after normal.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -