ID Number: Q47180
1.00 1.10 1.11 4.20
OS/2
Summary:
SYMPTOMS
According to the "Microsoft SQL Server Language Reference," you
can convert from a character to an integer. However, the
following statement
select convert(int,'A')
causes the following error:
syntax err converting char value 'A' to an INT4 field.
CAUSE
A convert() from a char to an integer can only be done if it
"makes sense." For example, you can convert the character "1"
(one) to an integer, but you cannot conevrt the letter "A".
For example
select convert(int,'1')
returns 1 as expected.
RESOLUTION
To return the ASCII numerical representation of a letter, use
the ascii() function. For example
select ascii('A')
returns 65.
Additional reference words: Transact-SQL