loading..
Русский    English
02:18

UNICODE and NCHAR functions

UNICODE(ncharacter_expression) returns the Unicode value for the first character of the input expression.

NCHAR(integer) returns a character with the given integer Unicode value.

There are few examples.

Console
Execute
  1. SELECT ASCII('а'), UNICODE('а')
returns the ASCII-code value and the Unicode value of the Russian letter "а": 224 and 1072.

Console
Execute
  1. SELECT CHAR(ASCII('а')), CHAR(UNICODE('а'))

Here we try to recover a symbol by its code value. We get "а" and NULL. The NULL-value returns because the 1072 code value is absent in the usual code table.

Console
Execute
  1. SELECT CHAR(ASCII('а')), NCHAR(UNICODE('а'))

Now it's all right, "a" in both cases. Finally,

Console
Execute
  1. SELECT NCHAR(ASCII('а'))
will give "à", because the Unicode value 224 exactly corresponds to this letter.

Bookmark and Share
Tags
aggregate functions Airport ALL AND AS keyword ASCII AVG Battles Bezhaev Bismarck C.J.Date calculated columns Cartesian product CASE cast CHAR CHARINDEX Chebykin check constraint classes COALESCE common table expressions comparison predicates Computer firm CONVERT correlated subqueries COUNT CROSS APPLY CTE data type conversion data types database schema date/time functions DATEADD DATEDIFF DATENAME DATEPART DATETIME DDL DEFAULT DEFAULT VALUES DELETE DISTINCT DML duplicates EXCEPT exercise (-2) exercise 19 exercise 23 exercise 32 More tags
The book was updated
month ago
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.
Rambler's Top100