String Function – ASCII()

I am going to write a series of very short articles or tidbits on Transaction SQL (TSQL) functions. I will start exploring the string functions today in alphabetical order.

Before the invention of UNICODE, we were able to express only 128 different characters with 7 bit ASCII code.

Transaction SQL (TSQL) still supports the ASCII() function that takes a CHAR or VARCHAR datatype as input and returns a INT datatype as output.

The following example returns the ASCII code for a space which is a value of 32.

One thing to always worry about when using TSQL functions is how will it react with a UNKNOWN or NULL value?

Next time, I will be exploring the CHAR() function.

Related posts

Leave a Comment