如何将 BCP 操作的错误消息写入日志文件并停止处理批处理文件。
我在批处理命令文件中有一个 BCP 操作。当 BCP 操作出现错误时,我需要停止处理并将错误消息写入日志文件中,
我使用 -e
选项将 BCP 操作期间的错误消息写入到错误文件。 err 文件正在该位置创建,但不包含写入其中的任何错误消息。
我的BCP声明是这样的。
BCP DbName.dbo.tableName In FileLocation -e Errorfile -S ServerName -T -c
有没有办法获取错误级别然后停止处理?
感谢快速帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
-m 参数指定最大错误数。 “bcp 实用程序无法复制的行将被忽略并计为一个错误。如果不包含此选项,则默认值为 10。”
-e 参数指定存储数据的文件,bcp 无法写入输出文件。
bcp 实用程序正在向 DOS 环境报告错误。从 DOS 脚本运行 bcp 并从 DOS 环境捕获/写入错误。
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.