在用 BCP 命令导入其它机器导出的文件很容易碰到这样的问题:
Server Message: cdr - Msg 2401, Level 11, State 2:
Character set conversion is not available between client character set 'iso_1' and server character set 'eucgb'.
Server Message: cdr - Msg 2411, Level 10, State 1:
No conversions will be done.
Starting copy...
CSLIB Message: - L0/O0/S0/N24/1/0:
cs_convert: cslib user api layer: common library error: The conversion/operation was stopped due to a syntax error in the source field.
CSLIB Message: - L0/O0/S0/N24/1/0:
cs_convert: cslib user api layer: common library error: The conversion/operation was stopped due to a syntax error in the source field.
这是由中文编码引起的。解决方法是在BCP命令后面跟上如下参数:
-Jeucgb 设置客户端编码方式,解决前面的字符编码告警。通常情况下客户端编码方式和服务器都不一样,即使在服务器上运行也是如此。
-zchinese 设置数据库语言,解决导入中文错误。此选项的值在 数据库安装目录/locales/下面能找到,各个文件夹就是可用的值。
另:通常使用 -c -t'|' 这样的参数来指定使用文本方式导入、管道符(|)为字段值分隔符。