Sometimes there is a weird character in a string, could be in a data exchange for example. The goal of this procedure is to find which ascii code this sign is so you can easily replace it. It makes it easier to find if the sign is a tab or maybe a return. In the example you will see that a return exists of 2 chars, the 13 and the 10.
declare @tab table (ascii_value int
-- create variables for the character string and for the current position in the string.
declare @position int = 1
,@string nvarchar(100) ;
set @string = '§
while @position <= len(@string)
insert into @tab
select ascii(substring(@string, @position, 1))
,char(ascii(substring(@string, @position, 1)))
set @position = @position + 1
select * from @tab