tags:

views:

108

answers:

1

I have a BCP operation in a batch command file. when there is an error in the BCP Operation I need to stop the processing and write the err msg in the log file

I've used to -e option to write the error message during a BCP operation to a err file. The err file is getting created in the location but does not contain any error message written to it.

My BCP statement is like this.

BCP DbName.dbo.tableName In FileLocation -e Errorfile -S ServerName -T -c

Is there a way to get the error level and then stop the processing.

Appreciate quick help.

A: 

The -m argument specifies max errors. "A row that cannot be copied by the bcp utility is ignored and is counted as one error. If this option is not included, the default is 10."

The -e argument specifies the file that the data is stored in that bcp cannot write to the output file.

The bcp utility is reporting the error to the DOS environment. Run bcp from a DOS script and capture/write the error from the DOS environment.

Chris Gallucci