SQL CHAR() | CHR() Function

SQL CHAR() | CHAR() Function


The SQL CHAR() | CHAR() is a function, and return a character (ascii value) that represent of a given input number from query result.

The SQL CHAR() | CHAR() function supports only numeric value which contains the ascii table.

It can be used in SELECT statement as well in where clause.



Sql chr function using sql character functions, sql char function, oracle character functions.

SQL CHAR() Syntax

For MS ACCESS / ORACLE


// Ascii value from a given input numeric value
SELECT CHAR(input_numeric_code);
// Ascii value from a given input numeric table column
SELECT CHAR(input_numeric_code_column) FROM table_name;

For SQL SERVER / MySql


// Ascii value from a given input numeric value
SELECT CHAR(input_numeric_code);
// Ascii value from a given input numeric table column
SELECT CHAR(input_numeric_code_column) FROM table_name;

SQL CHAR() Example - Using Expression Or Formula

The following SQL SELECT statement returns the character(ascii value) of a given input number.


SELECT CHAR(65) AS 'Ascii Character Of 65';

The result of above query is:

Ascii Character Of 65
A

SQL CHAR() Function More Example

Input Value Result
CHAR(67) C
CHAR(98) b
CHAR(50) 2
CHAR(50 + 15) A

Sample Database Table - Customer

CID CName Age City
65 Suresh Babu 72 Nasik
66 Suresh Kumar 56 Nasik
67 Vinoth Kumar 78 Chennai
68 Azagu Varshith 83 Madurai

SQL CHAR() Example - With Table Column

The following SQL SELECT statement find the ascii value of a given table column "CID" from the "Customer" table:


SELECT 
CID, CHAR(CID) As 'Ascii Character Of CID',
Age, CHAR(Age) As 'Ascii Character Of Age'
FROM Customer;

The result of above query is:

CID Ascii Character Of CID Age Ascii Character Of Age
65 A 72 H
66 B 56 8
67 C 78 N
68 D 83 S


Sql server char function using sql server char function, oracle replace character, find character in string sql, sql string functions, sql string functions with examples, sql query string functions, string functions in t sql.