CHAR()
Converts an int ASCII code to a character.
Syntax
CHAR ( integer_expression )
Converts an int ASCII code to a character.
Syntax
CHAR ( integer_expression )
Arguments: integer_expression: Is an integer from 0 through 255. NULL is returned if the integer expression is not in this range.
Return Types: character
Example:
SET TEXTSIZE 0
SET NOCOUNT ON
DECLARE @intCounter int
SET @intCounter = 0
WHILE (@intCounter<= 255)
BEGIN
SELECT 'CHAR - ' + CHAR(@intCounter) + '. ASCII - ' + CONVERT(VARCHAR,@intCounter)
SET @intCounter = @intCounter + 1
END
SET NOCOUNT OFF
Return Types: character
Example:
SET TEXTSIZE 0
SET NOCOUNT ON
DECLARE @intCounter int
SET @intCounter = 0
WHILE (@intCounter<= 255)
BEGIN
SELECT 'CHAR - ' + CHAR(@intCounter) + '. ASCII - ' + CONVERT(VARCHAR,@intCounter)
SET @intCounter = @intCounter + 1
END
SET NOCOUNT OFF
Output:
CHAR - !. ASCII - 33
------------------------------
CHAR - !. ASCII - 33
------------------------------
CHAR - ". ASCII - 34
------------------------------
CHAR - #. ASCII - 35
------------------------------
CHAR - $. ASCII - 36
------------------------------
CHAR - %. ASCII - 37
------------------------------
CHAR - &. ASCII - 38
------------------------------
CHAR - '. ASCII - 39
------------------------------
CHAR - (. ASCII - 40
------------------------------
No comments:
Post a Comment