Skip to content

Latest commit

 

History

History
81 lines (65 loc) · 2.69 KB

File metadata and controls

81 lines (65 loc) · 2.69 KB

title: "ASCII (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "07/24/2017" ms.prod: "sql" ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw" ms.service: "" ms.component: "t-sql|functions" ms.reviewer: "" ms.suite: "sql" ms.technology:

  • "database-engine" ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords:
  • "ASCII_TSQL"
  • "ASCII" dev_langs:
  • "TSQL" helpviewer_keywords:
  • "ASCII function"
  • "characters [SQL Server], ASCII"
  • "code [SQL Server], ASCII"
  • "leftmost character of expression" ms.assetid: 45c2044a-0593-4805-8bae-0fad4bde2e6b caps.latest.revision: 37 author: "edmacauley" ms.author: "edmaca" manager: "craigg" ms.workload: "Active" monikerRange: ">= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || = sqlallproducts-allversions"

ASCII (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2008-all-md]

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

Topic link icon Transact-SQL Syntax Conventions

Syntax

ASCII ( character_expression )  

Arguments

character_expression
An expression of type char or varchar.

Return types

int

Remarks

ASCII stands for American Standard Code for Information Interchange. It serves as a character encoding standard for modern computers. See the Printable characters section of ASCII for a list of ASCII characters.

Examples

This example assumes an ASCII character set, and returns the ASCII value for 6 characters.

SELECT ASCII('A') AS A, ASCII('B') AS B,   
ASCII('a') AS a, ASCII('b') AS b,  
ASCII(1) AS [1], ASCII(2) AS [2];  

[!INCLUDEssResult]

A           B           a           b           1           2  
----------- ----------- ----------- ----------- ----------- -----------  
65          66          97          98          49          50  

See also

CHAR (Transact-SQL)
NCHAR (Transact-SQL)
UNICODE (Transact-SQL)
String Functions (Transact-SQL)