Friday, September 30, 2011

Converts an int ASCII code to a character.

Char will convert an int ASCII code to a character. 
Syntax 
CHAR ( integer_expression ) 
Integer_expression
            Integer_expression is an integer from 0 through 255. NULL is returned if the integer expression is not in this range. 

Example  
Char(1) . . . . . . . Char(255)  
               CHAR can be used to insert control characters into character string. The following table shows some frequently used control characters.

Control character
value
Tab
Char(9)
Line feed
Char(10)
Carriage return
Char(13)


CREATE TABLE #Temp (id INT IDENTITY,symd CHAR(10))

DECLARE @I INT =1
WHILE (@I<=255)
BEGIN
INSERT INTO #Temp SELECT CHAR(@I)
SET @I =@I+1
END
SELECT id 'Char Value',symd 'Control character'  FROM #Temp

DROP TABLE #Temp

No comments:

Post a Comment