SQL Server/T-SQL Tutorial/String Functions/ASCII

Материал из SQL эксперт
Перейти к: навигация, поиск

ASCII returns the ASCII numeric value of the leftmost character of a string.

Only the first character in the string is evaluated.
40> DECLARE @ASCII_STRING CHAR(5)
41> SET @ASCII_STRING = "www.sqle.ru sqle"
42> SELECT ASCII(@ASCII_STRING)
43> GO
-----------
        119
(1 rows affected)


Converting a Character Value to ASCII and Back to Character

34>
35> SELECT ASCII("H"), ASCII("e"), ASCII("l"), ASCII("l"), ASCII("o")
36> GO
----------- ----------- ----------- ----------- -----------
         72         101         108         108         111
(1 rows affected)


Converting an ASCII Value to Character

3>
4> SELECT CHAR(72), CHAR(101), CHAR(108), CHAR(108), CHAR(111)
5> GO
- - - - -
H e l l o
(1 rows affected)
1>