SQL SERVER – ASCII to Decimal and Decimal to ASCII

ASCII – Returns the ASCII code value of the leftmost character of a character expression.

CHAR – Fixed-length non-Unicode character data with length of n bytes.

Examples:
----Decimal to ASCII
SELECT CHAR(80)+CHAR(73)+CHAR(78)+CHAR(65)+CHAR(76) AS SQLAuthorityAuthor
GO

----ASCII to Decimal
SELECT ASCII('P') AS SQLAuthorityAuthor
UNION ALL
SELECT ASCII('I')
UNION ALL
SELECT ASCII('N')
UNION ALL
SELECT ASCII('A')
UNION ALL
SELECT ASCII('L')
GO

Refer the ASCII-Decimal Table here.

Reference : Pinal Dave (http://blog.SQLAuthority.com)

About these ads

4 thoughts on “SQL SERVER – ASCII to Decimal and Decimal to ASCII

  1. Pingback: SQL SERVER – Weekly Series – Memory Lane – #030 | SQL Server Journey with SQL Authority

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s