Sets up the column format for the input file in a bulk-copy operation. This is a utility function that combines SqlBCPColumns% and SqlBCPColfmt% in one step.
SqlBCPColumnFormat% ( sqlconn%, col( ), numcols% )
where
When more than one means of specifying the column length of an operating-system file is used (such as a length prefix and a maximum column length, or a length prefix and a terminator sequence), the bcp utility uses the one that results in the shortest amount of data being copied.
One valuable use for length prefixes is to simplify the specifying of null data values in an operating-system file. For example, assume that you have a length prefix of 1 byte for a 4-byte integer column. Ordinarily, the length prefix contains a value of 4 to indicate that a 4-byte value follows. However, if the value of the column is an empty string, the length prefix can be set to 0 to indicate that 0 bytes follow.
For fixed-length datatypes such as integers, the length of the data is constant, except for the special case of null values. Therefore, for fixed-length datatypes, fcollen& must always be -1 except when the data is an empty string, in which case fcollen& must be 0. For character, text, binary, and image data, fcollen& can be -1, 0, or any positive value. If fcollen& is -1, the system uses either a length prefix or a terminator sequence to determine the length of the data. (If both are supplied, the system uses the one that results in the shorter amount of data being copied.) If fcollen& is - 1 and neither a prefix length nor a terminator sequence is specified, the system returns an error message. If fcollen& is 0, the system assumes that the data is an empty string. If fcollen& is a positive value, the system uses fcollen& as the maximum data length. However, if a positive fcollen& and a prefix length and/or terminator sequence are provided, the system determines the data length by using the method that results in the shortest amount of data being copied.
When more than one means of specifying the column length of an operating-system file is used (such as a terminator and a length prefix, or a terminator and a maximum column length), the bcp utility uses the one that results in the shortest amount of data being copied.
SUCCEED (1) or FAIL (0).
SqlBCPColumnFormat% is equivalent to calling SqlBCPColumns% (to set the number of columns) and repeated calls to SqlBCPColfmt% (to set the format).
The size of the col( ) array is equal to the number of columns (numcols%). To access an element of the col structure, you must use the point (.) notation. For example:
col.elementname
For example, the following statement sets the datatype of the column in the operating-system file:
Col.ftype% = SystemFileType%