Beginner

249. ASCII Function

Learn how to retrieve the numeric character code of the first character in a string.

📘 Lesson 249 of 728 ⏱ 8 min 🎯 Intermediate

The ASCII function returns the numeric ASCII code associated with the first character of a string in database systems that support ASCII.

Character codes can be useful in specialized text-processing and data-validation scenarios.

Return the ASCII code of the first character in a customer code.

SQL
SELECT
    CustomerCode,
    ASCII(CustomerCode) AS FirstCharacterCode
FROM Customers;

ASCII can be used for text analysis, validation, troubleshooting, and specialized data-processing tasks.

  • ASCII returns a numeric character code.
  • It generally examines the first character.
  • It is useful for specialized text processing.
  • Unicode requires different functions in some systems.
  • Database support varies.
What does ASCII return?

ASCII returns the numeric code associated with the first character of a string.

Is ASCII suitable for all languages?

No. ASCII covers a limited character set, so Unicode-specific functions may be needed for multilingual data.

Have you finished this lesson?

Introduction to SQL – All Lessons