ascii

Description

Returns the ASCII code for the first character in an expression.

Syntax

ascii(char_expr | uchar_expr)

Parameters

char_expr

is a character-type column name, variable, or constant expression of char, varchar, nchar or nvarchar type.

uchar_expr

is a character-type column name, variable, or constant expression of unichar or univarchar type.

Examples

Example 1

select au_lname, ascii(au_lname) from authors
where ascii(au_lname) < 70

 au_lname
 ------------------------------ -----------
 Bennet                                 66
 Blotchet-Halls                         66 
 Carson                                 67 
 DeFrance                               68 
 Dull                                   68 

Returns the authors last names and the ACSII codes for the first letters in their last names, if the ASCII code is less than 70.

Usage

Standards

SQL92 – Compliance level: Transact-SQL extension.

Permissions

Any user can execute ascii.

See also

Functions char, to_unichar