views:

49

answers:

2

Using standard SQL, SQL-92, how can I convert a character to an ASCII value?

In MySQL it's easy using the ascii() function, but SQL-92 doesn't have this.

+1  A: 

It appears the SQL-92 standard doesn't even mention ASCII at all.

As you say, each RDBMS vendor would have its own implementation how to convert char->ascii and ascii->char.

Most name this function ASCII().

p.campbell
A: 

Create a lookup table with all the ASCII characters and their corresponding values -- there are only 127 of them -- and then just do SELECT [value] FROM [table] WHERE [character] = 'A' etc.

LukeH