Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » String FunctionsRSS Feeds

ASCII Function

Posted By: Sarita Patel     Category: SQL Server     Views: 7711

This article explains about ASCII function and it's use in sql server with examples.

ASCII function is used to get ASCII code of leftmost character of a specified string expression.  

Syntax of ASCII Function :

ASCII(character_expression)


character_expression is an expression of char or varchar type.
It returns an integer value.

Example of ASCII Function :

Example 1 : Use of ASCII function in select clause

SELECT ASCII('SYNTAX')  

Output
83

Above example displays ASCII value of leftmost character as capital 'S'. 




Example 2 : Use of ASCII function in where clause

SELECT ShipName
FROM   Orders  
WHERE  ASCII(ShipName) = 83

Output
ShipName
Suprêmes délices
Split Rail Beer & Ale
Suprêmes délices
Save-a-lot Markets
Split Rail Beer & Ale

Above query displays all orders having first character ascii value as 83 or starting with capital 'S'.
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on ASCII Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of ASCII Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!