bcp discard file support for rejected rows

Originally, the bcp parameter maxerrors had to be set to a high value and the parameter batchsize set to 1, to identify the rows that were rejected due to exceptions such as duplicate rows or errors in the batch file. This method was not efficient and made it hard to identify, debug, and reload the rows that were rejected.

With the introduction of the new bcp option -d discardfileprefix you can now log the rejected rows into a dedicated discard file that has the same format as the host file. The discard file is created by appending the input file name to the discard file prefix supplied. You can correct the rows in this file and use it to reload the corrected rows.

Syntax

bcp -d discardfileprefix

Examples

This example creates the discard file reject_titlesfile.txt:

bcp pubs2..titles in titlesfile.txt -d reject_

Usage

NoteIf the discard file option is specified, the batch size is automatically adjusted and the message “Warning!!! Batch size adjusted to the value newbatchsize, for the optimization of the discard file feature.” is displayed, when:

New error messages