Is it Available to put ascii values into variable in sql server 2008 r2? I trying this code:
declare @thechars varchar(15)
declare @theascii varchar(50)
declare @position int
set @thechars = 'somechar'
set @theascii = ''
set @position = 1
while(@position<16)
begin
set @theascii = @theascii+convert(varchar,ascii(substring(@thechars ,@position,1)))
set @position = @position + 1
end
print '-------------------------'
print 'the ascii is ' + @theascii
print '-------------------------'
but the result just like this:
-------------------------
-------------------------
is there any way to solve my problem?