Checking the Validity of the Saved Data

You can use the Transact-SQL string function ASCII(char_expr) to reveal the character that is saved in the SQL Server database. You can also use the ASCII(column_name) function to reveal the ASCII value for a particular column in the database.

For example, assume you have saved the character "±" on a server with code page OEM 437. If you select this data from ISQL/w (which has a code page of ANSI 1252) when AutoANSItoOEM is on, you will see the "±" character. AutoANSItoOEM has converted the OEM 437 "±" (which has an ASCII value of 241) to the ANSI 1252 "±" (which has an ASCII value of 177). However, if you select the data from ISQL/w when AutoANSItoOEM is off, you will see the "ñ" character. AutoANSItoOEM has not converted the OEM 437 ASCII value of 241 but instead has retrieved the character for the ANSI 1252 ASCII value of 241.

Code page

Character ±

AutoANSItoOEM ON

AutoANSItoOEM OFF

OEM 437

ASCII 241

±

±

ANSI 1252

ASCII 177

±

ñ (ASCII 241)


Another way to reveal the code page is to set AutoANSItoOEM to OFF and then query the data both from a Windows tool and from isql at a command prompt.