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

Returns the author’s last names and the ACSII codes for the first letters in their last names, if the ASCII code is less than 70:

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 

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute ascii.

See also

For general information about string functions, see “String functions”.

Functions char, to_unichar