NCHAR
NCHAR( integer_expression )
Section titled “NCHAR( integer_expression )”- integer_expression: This parameter specifies the length for the NCHAR function; it defines the number of characters to be returned. The value must be between 1 and 4000. Although the input can be a constant, variable, or returned from a scalar function, it must always be an integer. The function will return a Unicode string of fixed length, with the length specified being the length of the returned string.
Example
Section titled “Example”SELECT NCHAR(65);Output
Section titled “Output”AExplanation
Section titled “Explanation”The NCHAR function in SQL Server converts an integer ASCII code to a character. Here, it converts ASCII code 65, which corresponds to the letter ‘A’, into its corresponding character representation.
NCHAR(n)
Section titled “NCHAR(n)”- n: This is the length of the string that will be returned by the NCHAR function. It determines the number of characters or the size of the characters that the function will accommodate. If n is not specified, the function will return a single character. The maximum size allowed is 2000 bytes.
Example
Section titled “Example”SELECT NCHAR(2673) as Planet_Symbol FROM dual;Output
Section titled “Output”Planet_Symbol-------------♄Explanation
Section titled “Explanation”The NCHAR function converts numbers into Unicode characters. In this case, it converts the number 2673 to the Unicode symbol for the planet Saturn (♄).