Plus N indicates that the database is stored in Unicode format. Nstring indicates that a string is a Unicode string in a format similar to a common string, but it has an N identifier before it (N stands for the international language (NationalLanguage) in the SQL-92 standard )). The N prefix must be an uppercase letter. For example, michél is
Plus N indicates that the database is stored in Unicode format. N 'string' indicates that a string is a Unicode string in a format similar to a common string, but it is preceded by an N identifier (N stands for the international Language in the SQL-92 standard )). The N prefix must be an uppercase letter. For example, 'michél' is
Plus N indicates that the database is stored in Unicode format. N 'string' indicates that a string is a Unicode string in a format similar to a common string, but it is preceded by an N identifier (N stands for the international Language in the SQL-92 standard )). The N prefix must be an uppercase letter. For example, 'michél' is a String constant, while n'michél' is a Unicode constant. Unicode constants are interpreted as Unicode data and are not calculated using the code page. Unicode constants do have sorting rules, mainly used to control comparison and Case sensitivity. Assign the default sorting rules of the current database to Unicode constants unless the sorting rules are specified for them using the COLLATE clause. Each character in Unicode data is stored in two bytes, while each character in character data is stored in one byte. For more information, see use Unicode data. Unicode string constants support enhanced sorting rules. NCHAR is defined according to the Unicode Standard and returns Unicode characters with the given integer code. The NCHAR (integer_expression) parameter indicates all positive integers between 0 and 65535. If a value out of this range is specified, NULL is returned. Return type nchar (1) Example A. Use NCHAR and UNICODE the following example uses the UNICODE and NCHAR functions to print the string K? The UNICODE value and NCHAR (Unicode character) of the second character of enhavn, and the actual second character? is printed ?. DECLARE @ nstring nchar (8) SET @ nstring = n' K? Benhavn 'select UNICODE (SUBSTRING (@ nstring, 2, 1), NCHAR (UNICODE (SUBSTRING (@ nstring, 2, 1) below is the result set: ------------248? (1 row (s) affected) B. Use the SUBSTRING, UNICODE, CONVERT, and NCHAR functions below to print the string K? The number of enhavn characters, Unicode characters, and the UNICODE value of each character. DECLARE @ position int, @ nstring nchar (9) SET @ position = 1 SET @ nstring = n'k? Benhavn 'print 'character # '+ ''+ 'unicode Character' +'' + 'unicode value' WHILE @ position <= DATALENGTH (@ nstring) begin select @ position, NCHAR (UNICODE (SUBSTRING (@ nstring, @ position, 1), CONVERT (NCHAR (17), SUBSTRING (@ nstring, @ position, 1 )), UNICODE (SUBSTRING (@ nstring, @ position, 1) SELECT @ position = @ position + 1 ENDGO contains the result set: Character # Unicode Character UNICODE Value ------------------- --------- ----------- 1 K 75 ----------- ----------------- ----------- 2? 248 ----------- hour ----------- 3 B 98 ----------- hour ----------- 4 e 101 ----------- hour ----------- 5 n 110 ----------- hour ----------- 6 h 104 ----------- hour ------------- 7 a 97 hour before 8 v 118 hour --------------------------------------- 9 n 110 ----------- ----------------- ----------- 10 (null) (null) ----------- hour ----------- 11 (null) ----------- --------------- ----------- 12 (null) ----------- hour ----------- 13 (null) ----------- hour ----------- 14 (null) (null) ----------- hour ----------- 15 (null) ----------- --------------- ----------- 16 (null) ----------- hour ----------- 17 (null) ----------- hour ----------- 18 (null) (null)