Thursday, 25 June 2009

Find ASCII values of each character in a string

-----------------------------
declare @string varchar(1000)

set @string = 'Nazer'
declare @i int, @length int
set @length = len(@string)
set @i = 1

while (@i <= @length)
Begin
print cast(ascii(substring(@string, @i, 1)) as char(3)) + ' - ' + substring(@string, @i, 1)
set @i = @i + 1
End
---------------------------------

No comments:

Post a Comment