How to find ASCII code in sql server

ASCII means American Standard Code for Information Interchange.
This function is use to find the ASCII code value of the leftmost character in the string.

Syntax : ASCII(‘Character_expression’)

Character Expression – value can be char or varchar type.

Example

Declare @str varchar(20)
Set @str = ‘ANIL’

declare @count int
Set @count = 1

while (@count <= len(@str))
begin

select ‘Character’= substring(@str,@count,1),’ASCII Value’ = ASCII(substring(@str,@count,1))

set @count=@count+1
end

Leave a Reply

  

  

  


5 + = 14