What does it mean when BCP fails ("BCP copy in failed"), but not -e error log contents generated?

2.5k views Asked by At

Using BCP from mssql-tools on CentOS7 and trying to copy some TSV data into a local MSSQL DB, BCP fails to do the copy and throws error "BCP copy in failed". The command being run is:

TO_SERVER_ODBCDSN="-D -S MyMSSQLServer"
RECOMMEDED_IMPORT_MODE='-c' # makes a big difference, see https://stackoverflow.com/a/16310219/8236733
/opt/mssql-tools/bin/bcp "$TABLE" in "$filename" \
        $TO_SERVER_ODBCDSN \
        -U $USER -P $PASSWORD \
        -d $DB \
        $RECOMMEDED_IMPORT_MODE \
        -t "\t" \
        -e ${filename}.bcperror.log

Yet the error logs created by the command are empty. What does this mean / imply? Anyone have any further debugging tips for resolving the "copy in failed" error?

1

There are 1 answers

1
jamie On BEST ANSWER

The errorlog created when you use the -e option is meant to capture errors regarding the data itself. So, the errorlog will contain errors when there is an overflow of data (too many bytes in a field destined for a column with too few).

Execution errors, or errors with the BCP application itself are not captured in the error file created by the -e option.

In an automated environment, if you want to capture or log such errors you will need to redirect the output of the BCP command to a file for viewing later or even loading into a log table in a SQL table.