CHAR function in SQL Server

CHAR function in SQL Server is used to convert an integer expression into the corresponding character in ASCII code.

The article will explore and show you how to use the CHAR function in SQL Server to convert ASCII code values ​​into characters.

Describe

CHAR function in SQL Server is used to convert an integer expression into the corresponding character in ASCII code.

The CHAR function is used against the ASCII Quantrimang function introduced in the previous article.

Syntax

To run CHAR function in SQL Server, we use the following syntax:

 CHAR(bieu compare it) 

Parameters :

  1. How to compare : an integer value from 0 to 255 . If the integer expression is a value outside of this range , CHAR () will return NULL .

CHAR function can only be used in later versions of SQL Server: SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005.

For example

Take a look and explore some examples of CHAR functions in SQL Server.

 SELECT CHAR('113'); 
Result: q

SELECT ASCII('81');
Result: Q

See also: ASCII encoding and Latin character table ISO 1252

Last lesson: ASCII function in SQL Server

Next lesson: CHARINDEX function in SQL Server

5 ★ | 1 Vote