Sql Server Char Function

SQL Server: CHAR Function

In this post explains how to use the CHAR function in SQL Server (Transact-SQL) with syntax and examples.

Description

In SQL Server (Transact-SQL), the CHAR function is the opposite of the ASCII function. It returns the character based on the NUMBER code.

Syntax

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

CHAR( number_code )

Parameters or Arguments

number_code

The ASCII NUMBER code used to retrieve the character.

Applies To

The CHAR 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 CHAR function examples and explore how to use the CHAR function in SQL Server (Transact-SQL).

For example:

SELECT CHAR(116);
Output: 't'

SELECT CHAR(84);
Output: 'T'