Beginner

321. ASCII Function

Learn how to return the numeric ASCII code of a character.

📘 Lesson 321 of 728 ⏱ 8 min 🎯 Intermediate

The ASCII function returns the numeric ASCII value associated with the first character of a string.

ASCII values can help when analyzing, validating, or troubleshooting text data at the character level.

Find the ASCII value of the first character of an employee code.

SQL
SELECT
    EmployeeCode,
    ASCII(EmployeeCode) AS ASCIIValue
FROM Employees;

ASCII can be useful in data validation, text processing, system integration, and troubleshooting encoded values.

  • ASCII returns a numeric character code.
  • It normally evaluates the first character.
  • It is useful for character-level analysis.
  • It can support validation.
  • Character encoding support varies by database.
What does ASCII return?

ASCII returns the numeric ASCII code associated with a character.

Which character is normally evaluated by ASCII?

The first character of the supplied string is normally evaluated.

Have you finished this lesson?

Introduction to SQL – All Lessons