Wednesday, 20 July 2016

How To Find the ASCII Value of each character in your String – SQL Server


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

DECLARE @counter int = 1;DECLARE @colString varchar(10) = 'AA%#& ';
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