A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  special characters  sybase-tech-blog


Category: ASE: Datatypes: Character Datatypes

nchar

The term nchar(n) describes a datatype. Like all character datatypes, the datatype nchar(n) is also compatible to the ANSI-Standard. The values which can be stored in columns defined with nchar(n), are always of the fixed length n (fixed-length character string). Therefor, the datatype nchar(n) always requires n bytes of storage, independent from the length of the character string. Strings longer than n are cut off after the nth character. The range for the variable n is between 1 and 255 (ASE-version 12.0) and between 1 and 16384 (starting with ASE-version 12.5). The exact value for the required storage in bytes can be determined using the formula "n * @@ncharsize".

Usage of the Datatype nchar(n)

The datatype nchar(n) can be used for storing character sets with a predictable fixed length (fixed-length character string) or which are no longer than 5 characters. Examples can be post codes, insurance or customer numbers. nchar(n) should be used if the "character set" to be used requires more than one byte of storage per character, i.e. for so-called multibyte character sets, like for example Japanese or Chinese. For singlebyte character sets, like for example for Englisch the datatype char(n) is sufficient.

See also:

nvarchar,
text,
unichar(n),
univarchar(n),
varchar(n).