The CHAR
function converts an integer to a single-byte character.
The returned character is based on the encoding in the current database collation.
Commonly used characters include: 9 (tab), 10 (line feed), and 13 (carriage return).
This example returns single-byte characters for the given integer values.
SELECT CHAR(68) AS '68',
CHAR(112) AS '112',
CHAR(57) AS '57',
CHAR(189) AS '189',
CHAR(216) AS '216'
68 | 112 | 57 | 189 | 216 |
---|---|---|---|---|
D | p | 9 | ½ | Ø |
Syntax of the CHAR function.
CHAR(integer)
integer
-- an integer from 0 to 255. Any other value returns NULL.
CUSTOMER |
---|
Id |
FirstName |
LastName |
City |
Country |
Phone |
SELECT FirstName + ' ' + LastName + CHAR(13) +
Phone AS Customer
FROM Customer
Customer |
---|
Marias Anders 030-0074321 |
Ana Trujillo (5) 555-4729 |
Antonio Moreno (5) 555-3932 |
Thomas Hardy (171) 555-7788 |
Christina Berglund 0921-12 34 65 |