Tuesday, February 26, 2013

SQL Server's CHAR Function

In my previous posts, I explained ASCII Function, Simple script to backup all SQL Server databases, Table-Valued Parameters and some other articles related to SQL Server. 

Here, I am going to explain the CHAR function of SQL Server.

CHAR() Function

This function converts an integer ASCII code value to its corresponding character value.

Syntax- CHAR(interger_expression)
Arguments- interger_expression: An expression of type int from 0 to 255. If the integer expession is not in this range then it returns NULL.
Return Type- char(1)

Example-
Declare @value as int
set @value=101
select CHAR(@value)
--output e

Declare @value as int
set @value=258 -- value is out of range 0 to 255
select CHAR(@value)
--output NULL


No comments:

Post a Comment

^ Scroll to Top