ASCII function is used to get ASCII code of leftmost character of a specified string expression.
Syntax of ASCII Function :
ASCII(character_expression)
character_expression is an expression of char or varchar type.
It returns an integer value.
Example of ASCII Function :
Example 1 : Use of ASCII function in select clause
SELECT ASCII('SYNTAX')
Output
83
Above example displays ASCII value of leftmost character as capital 'S'.
Example 2 : Use of ASCII function in where clause
SELECT ShipName
FROM Orders
WHERE ASCII(ShipName) = 83
Output
ShipName
Suprêmes délices
Split Rail Beer & Ale
Suprêmes délices
Save-a-lot Markets
Split Rail Beer & Ale
Above query displays all orders having first character ascii value as 83 or starting with capital 'S'.