I have a batch file that execute SQL scripts through sqlplus:
(
echo @"./myUTF8.sql"
echo @"./myAnsi.sql"
) | sqlplus uset/pwd@mybd
Unfortunately these SQL scripts are generated in different encoding, Ansi, UTF8, ...
How can I tell sqlplus that a script is of a specified encoding?
You have to change encoding with command chcp
, e.g. chcp 65001
for UTF-8 or chcp 1252
for Windows 1252. Term "ANSI" is just a general name for many different encodings. See column "ANSI codepage" at this National Language Support (NLS) API Reference to get codepage for you locale.
If you have to change the encoding inside a SQL script use host chcp ...
However, you also have to set NLS_LANG
environment variable accordingly. So after you have changed codepage you must also run for example SET NLS_LANG=.AL32UTF8
or SET NLS_LANG=.WE8MSWIN1252
.
See OdbcConnection returning Chinese Characters as "?" for more details.