List of int ASCII code to character in SQL Server 2005

Saturday, April 11, 2009 |

Sometime we need to character of ASCII code for many programming concern. Once, I had requirement not to allow any character other than few decided character in string. I created one temp table and by iterating loop, I added non-required character in that temp table and fire update query which remove non-required character from string. Anyway, this is something else and I will post this script later but right now I want to display character from its ASCII int in loop. I will iterate one loop for 256 times and will print all character with its ASCII int code.

DECLARE @counter INT

SET @counter=0

WHILE @counter<=255


print convert(varchar,@counter)+'==>'+CHAR(@counter)

SET @counter=@counter+1


Reference: Ritesh Shah
Note: Microsoft Books online is a default reference of all articles but examples and explanations prepared by Ritesh Shah, founder of


Hyousef said...

Cool script thanks man, helped me :)