SQL Server Hosting – HostForLIFE.eu :: ASCII Character in SQL Server


  • American Standard Code for Information Interchange.
  • Computer can understand only numbers.
  • ASCII is the numeric representation of a character.


SELECT CHAR(Expression)

A string function that converts an int ASCII code to a character.

Return type is CHAR.

Expression is integer value i.e. range from 0 to 255


SELECT CHAR(97) AS [ASCII Character of Number 97]

SELECT ASCII(‘a’)  AS [ASCII Number of  Character a]

SELECT CHAR(65) AS [ASCII Character of Number 67]

SELECT ASCII(‘A’) AS [ASCII Number of  Character A]



ASCII Values

  1. Characters Set 0-31First 32 Characters in the ASCII table are unprintable.
  2. Characters Set 32-127Characters from 32-127 are common for all which represent letters, digits, punctuation marks & miscellaneous symbols.
  3. Character Set 128-255Characters from 128-255 contains the Microsoft Latin-1 extended characters.

    –Example to display All Number & ASCII characters

    ;WITH AllNumbers AS


    SELECT 0 AS First_No

                UNION ALL

                SELECT First_No+1

                FROM AllNumbers

                WHERE First_No<255


    SELECT First_No as [Numbers],

                   CHAR(First_No) as [ASCII Value]

    FROM AllNumbers

                  OPTION (MAXRECURSION 255)


    Syntax in Oracle

    CHR(expression [using NCHAR_CS])

    Syntax in IBM DB2, Sybase


HostForLIFE.eu SQL Server 2016 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.