Thursday, June 23, 2011

Find ANSII Values

Here’s a simple query that lists the ASCII Value of each character in your string in SQL Server

DECLARE @counter int;
DECLARE @colString varchar(Max)
 set @colString='THE ‘SINGUR';
Set @counter=1;

WHILE @counter <= DATALENGTH(@colString)
   BEGIN
   SELECT CHAR(ASCII(SUBSTRING(@colString, @counter, 1))) as [Character],
   ASCII(SUBSTRING(@colString, @counter, 1)) as [ASCIIValue]
    
   SET @counter = @counter + 1
   END
GO

No comments:

Post a Comment