SQL Server: ASCII Function

ASCII functions

This SQL Server tutorial explains how to use the ASCII functions in SQL Server (Transact-SQL) with syntax and examples.

Description

In SQL Server (Transact-SQL), the ASCII functions returns the NUMBER code that represents the specified character. It is the opposite of the CHAR function.

Syntax

The syntax for the ASCII function in SQL Server (Transact-SQL) is:

ASCII( single_character )

Parameters or Arguments

single_characterThe specified character to retrieve the ASCII NUMBER code for. If more than one character is entered, the ASCII function will return the value for the first character and ignore all of the characters after the first.

Applies To

The ASCII function can be used in the following versions of SQL Server (Transact-SQL):

  • SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005

Example

Let’s look at some SQL Server ASCII function examples and explore how to use the ASCII function in SQL Server (Transact-SQL).

For example:

SELECT ASCII('t');
Result: 116

SELECT ASCII('adglob.in');
Result: 116

SELECT ASCII('T');
Result: 84

SELECT ASCII('adglob.in');
Result: 84

View a listing of the ASCII values.

Leave a Reply