NCHR
NCHR is a function in SQL that returns the Unicode character based on the number code. It is typically utilized for dealing with international characters not represented in the ASCII character set.
NCHAR( integer_expression )
- integer_expression: This parameter specifies the length for the NCHAR data type. Its value must be a valid integer from 1 through 4,000. The integer_expression references the number of Unicode characters that the NCHAR function will hold. This number does not vary according to the national character set.
Example
Output
Explanation
This script uses the NCHAR function to convert the numeric value (9731) to a unicode character (☃) in SQL Server.
NCHR(character_set, number_expression)
- character_set: This parameter specifies the character set for the output result. It is an ID that represents a particular set of characters. These sets can range widely in size and complexity, from basic ASCII characters to complex special symbols in various dialects.
- number_expression: This parameter denotes the Unicode code point of the character to be returned. In simpler terms, it’s a numerical expression that stands for a specific character in Unicode. For example, the Unicode code point for ‘A’ is 65. If 65 is used as the number expression, NCHR will return the character ‘A’.
Example
Output
Explanation
The NCHR
function in Oracle SQL returns the Unicode character based on the numeric value provided. In the given example, NCHR(100)
returns the Unicode character corresponding to the number 100 which is ‘d’.