Elements of the bcp format file

The following list names the various elements of a bcp format file. Use Figure 4-3 as the format file example.

The following sections describe the column elements in the format file.

Host file column order

The host file column order is the sequential number of the field in the host data file, which begins numbering at 1.

Host file datatype

The host file datatype refers to the storage format of the field in the host data file, not the datatype of the database table column. The host file datatypes and their storage formats are:

Data written to a host file in its native format preserves all of its precision. datetime and float values preserve all of their precision, even when they are converted to character format. Adaptive Server stores money values to a precision of one ten-thousandth of a monetary unit. However, when money values are converted to character format, their character format values are recorded only to the nearest two places.

See Chapter 1, “System and User-Defined Datatypes” in the Reference Manual: Building Blocks for descriptions and appropriate uses of Adaptive Server datatypes.

Prefix length

Prefix length indicates the number of bytes in the field length prefix. The prefix length is a 0-, 1-, 2-, or 4-byte unsigned integer value embedded in the host data file that specifies the actual length of data contained in the field. Some fields may have a length prefix while others do not.

Table 4-7 shows the allowable prefix length values.

Table 4-7: Allowable prefix length values

Length (in bytes)

Range

0

No prefix

1

28-1; 0-255

2

216-1; 0-65535

4

232 -1; 0-4,294,967,295

Host file data length

Host file data length refers to the maximum number of bytes to copy for the field. To decide how much data to copy in or out, bcp uses one of:

If more than one method of field length specification is given, bcp chooses the one that copies the least amount of data.

Terminator

The terminator can be up to 30 bytes of characters enclosed in quotation marks (" "). The terminator designates the end of data for the host data file field.

Server column order

The server column order represents the colid (column ID) of the syscolumns column into which the host data file column is to be loaded. Together with the host file column order, this element maps host data file fields to the database table columns.

Server column name

The server column name is the name of the database table column into which this field is to be loaded.

Column precision

The column precision is the precision of the database table column into which this field is to be loaded. This element is present only if the storage format is numeric or decimal.

Column scale

The column scale is the scale of the database table column into which this field is to be loaded. This element is present only if the storage format is numeric or decimal.