4. SQL Statements : COPY : Column Formats for COPY : Counted Character Formats
 
Share this page                  
Counted Character Formats
The NVARCHAR(n) and VARCHAR formats are "counted" formats: each data file value is preceded by a character count. The character count defines the length of the data value; the actual field length as defined by a fixed-length specifier or a delimiter may be larger. On input (COPY FROM), extra field characters beyond those included by the embedded character count are ignored. On output (COPY INTO), any extra field length after the actual value is filled with padding, as defined by the specific format.
The fixed-length forms are NVARCHAR(n) and VARCHAR(n). The variable-length form is VARCHAR(0). An optional delim can follow to specify a delimiter.
Note:  NVARCHAR(0) is not a counted format.
For all fixed-length counted formats: the field length N does not include the preceding length specifier. For example, a VARCHAR(1) field takes 6 bytes. When reading data (COPY FROM), if the character count found in the data is larger than the defined length, a runtime conversion warning is issued and the row is not loaded.