开发者

How to write an error message from an BCP operation to a log file and stop processing the batch file.

I have a BCP o开发者_运维问答peration 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜