Was this helpful?
Nchar Data Type
Fixed-length nchar strings can contain any printing or non-printing character, and the null character ('\0'). In uncompressed tables, nchar strings are padded with blanks to the declared length. (If the column is nullable, nchar columns require an additional byte of storage.) For example, if ABC is entered into a nchar(5) column, five bytes are stored, as follows:
'ABC  '
Leading and embedded blanks are significant when comparing nchar strings. For example, the following nchar strings are considered different:
'A B C'
'ABC'
When selecting nchar strings using the underscore (_) wildcard character of the like predicate, include any trailing blanks to be matched. For example, to select the following nchar string:
'ABC '
the wildcard specification must also contain trailing blanks:
'_____'
Length is not significant when comparing nchar strings; the shorter string is (logically) padded to the length of the longer. For example, the following nchar strings are considered equal:
'ABC'
'ABC '
Last modified date: 01/30/2023