Use of CHAR function in SQL

Use of CHAR function in SQL:

(1) “CHAR” function is used to get the first CHARACTER from ASCII Value.

(2) Let’s take an example to get CHAR from the ASCII Value field from the Vendor table as shown.

(3) Select the database in the SQL server and click on the “New Query” button as shown.

Select the database in SQL server and click on the New Query

(4) After that new query editor opens as shown.

new query editor open in sql

(5) After doing the above steps, write a query in the editor, as shown.

char function query in sql editor

Source Code:

–//CHAR Value get form ASCII Value field
select TB1.[Vendor No.],TB1.[Vendor Name],TB1.[ASCII Value of Vendor Name],
Char(TB1.[ASCII Value of Vendor Name])as [Char from ASCII Value]
from (Select [No_] as [Vendor No.],[Name] as [Vendor Name],
ASCII(Name)as [ASCII Value of Vendor Name]
fromdbo.[CRONUS India Ltd_$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972] TB1) TB1
–//CHAR Value get form ASCII Value field

(6) Then Execute or Press F5 to run the query and see the result as shown.

execute char query by F5

Use of ASCII function in SQL
Use of UPDATE Statement in SQL
Use of GROUP BY Statement in SQL
Use of ALIASES operator in SQL
CHAR (Transact-SQL)– Microsoft Docs

Leave a Reply