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.
1 2 3 4 5 |
-- A simple space declare @var_tmp char = ' '; -- Return ascii # select ascii(@var_tmp) as ascii_code; |
1 2 3 4 5 |
output: ascii_code ----------- 32 |
…