Specifies the format of an operating-system file in a bulk copy into or out of SQL Server.
SqlBCPColfmt% ( sqlconn%, fcolumn%, ftype%, fplen%, fclen&, fterm$, ftlen%, tcol% )
where
For a bulk copy out of SQL Server into a file, when ftype% is SQLDECIMAL or SQLNUMERIC:
If 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), DB-Library uses the one that results in the shortest amount of data being copied.
One valuable use of length prefixes is to simplify the specification of null data values in an operating-system file. For example, assume that you have a 1-byte length prefix 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 NULL, 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 in the special case of null values. Therefore, for fixed-length datatypes, fclen& must always be -1 except when the data is NULL, in which case fclen& must be 0. For character, text, binary, and image data, fclen& can be
- 1, 0, or any positive value. When fclen& 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 fclen& is -1 and neither a prefix length nor a terminator sequence is specified, the system returns an error message. If fclen& is 0, the system assumes the data is NULL. If fclen& is a positive value, the system uses fclen& as the maximum data length. However, if a positive fclen& 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.
If 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), DB-Library uses the one that results in the shortest amount of data being copied.
SUCCEED (1) or FAIL (0).
SqlBCPColfmt% specifies the format of the operating-system file for bulk copies. The format of a bulk-copy operation contains the following parts:
Each call to SqlBCPColfmt% specifies the format for one column in the operating system file. For example, when you have a table with five columns and want to change the default settings for three of those columns, first call SqlBCPColumns%(5), and then call SqlBCPColfmt% five times, with three of those calls setting your custom format. Set ftype% for the remaining two calls to 0 and fplen%, fclen&, and ftlen% to -1. These settings copy all five columns ¾ three with your customized format and two with the default format.
You must call SqlBCPColumns% before you call SqlBCPColfmt%.
You must call SqlBCPColfmt% once and only once for every column in the operating-system file, regardless of whether those columns use the default format or are skipped.
To skip a column, set tcol% to 0.
SqlBCPColumnFormat%, SqlBCPColumns%, SqlBCPControl%, SqlBCPExec%, SqlBCPInit%