Other related articles:

Recently viewed articles:

SQL ASCII Function

SQL ASCII function is used to return the ASCII (American Standard Code for Information Interchange) representation of the leftmost character of a string. If string contains no characters, a NULL value is returned. An error will be returned when a value for the string argument is not specified. The syntax is

ASCII (CHARACTER SET)

Example 1:

The following SQL ASCII query returns 65, which is the ASCII code for capital “A”.

SELECT ASCII('A') FROM dual;

Output:
sql-ascii-image1

Example 2:

The following SQL ASCII query also returns 65, which is the ASCII code for “A”.

SELECT ASCII('ABC') FROM dual;

Output:
sql-ascii-image2

Example 3:

The following query returns 97, which is the ASCII code for small “a”.

SELECT ASCII('a') FROM dual;

Output:
sql-ascii-image3

Example 4:

The following query returns NULL:

SELECT ASCII(‘‘ ) FROM dual;