SQL Server: CHAR Function

CHAR function

This SQL Server tutorial 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 functions in SQL Server (Transact-SQL) is:

CHAR( number_code )

Parameters or Arguments

number_codeThe ASCII NUMBER code used to retrieve the character.

Applies To

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

For example:

SELECT CHAR(116);
Result: 't'

SELECT CHAR(84);
Result: 'T'

View a listing of the ASCII values.

This Post Has One Comment

Leave a Reply