SQL Server CHAR() Function

The CHAR() function in SQL Server converts an ASCII (American Standard Code for Information Interchange) code into its corresponding character.

CHAR(): Definition and Usage

ASCII is a numerical representation of characters. Each character (like 'A', 'b', '!', etc.) has a unique numerical code. The CHAR() function takes this numerical code as input and returns the character itself. This is helpful when you need to work directly with character codes, for example, when dealing with specific character sets or when you have character codes stored in your database.

Syntax

Syntax

CHAR(code)
      

Parameter Values

Parameter Description
code The ASCII code (an integer) for which you want to retrieve the character. This is required.

Example

Converting an ASCII Code to a Character

This example demonstrates how to convert ASCII code 65 (which represents the uppercase letter 'A') to its character equivalent.

Syntax

SELECT CHAR(65) AS CodeToCharacter;
      
Output

A
      

Technical Details

The CHAR() function is available in:

  • SQL Server (starting with version 2008)
  • Azure SQL Database
  • Azure SQL Data Warehouse
  • Parallel Data Warehouse