CHAR function [String]

Returns the character with the ASCII value of a number.

Syntax

CHARinteger-expression )

Parameters

Parameter

Description

integer-expression

The number to be converted to an ASCII character. The number must be in the range 0 to 255, inclusive.

Returns

VARCHAR

Examples

The following statement returns the value “Y”:

SELECT CHAR( 89 ) FROM iq_dummy

The following statement returns the value “S”:

SELECT CHAR( 83 ) FROM iq_dummy

Usage

The character in the current database character set corresponding to the supplied numeric expression modulo 256 is returned.

CHAR returns NULL for integer expressions with values greater than 255 or less than zero.

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Compatible with Adaptive Server Enterprise.