Hana数据库 Conversion of parameter/column from data type VARCHAR1 to ASCII failed

While one of SQL developers was working on a database query which connects and queries remote data source, a SAP HANA database using SQL Server Linked Server connection, he has experienced following error:

OLE DB provider "STREAM" for linked server "(null)" returned message "[SAP AG][LIBODBCHDB DLL][HDBODBC] General error;-10427 Conversion of parameter/column (2) from data type VARCHAR1 to ASCII failed".
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.

For solution of "Conversion of parameter/column from data type VARCHAR1 to ASCII failed" errors, follow the steps:
Identify the LinkedServer where SQL programmers experience the error.
On SQL Server Management Studio, when you are connected to the SQL Server instance find the LinkedServer under "Server Objects > Linked Servers" nodes.
Right click on Linked Server node and display Properties window
Identify the ODBC data source name on Linked Server Properties window General tab.

SQL Server Linked Server ODBC data source

Launch ODBC Data Source Administrator application.
On "System DSN" tab, select the data source that is used by the SQL Server Linked Server connection.
Press "Configure" button and then "Settings" button for managing "Advanced ODBC Connection Property Setup" options.

Press "Add" button to add a new ODBC connection property CHAR_AS_UTF8 with value "true" as seen in following screenshot.

add advanced connection property for SAP HANA ODBC connection

Default value for "CHAR_AS_UTF8" connection property is "false"
If "CHAR_AS_UTF8" connection property is used then connection returns CHAR data in UTF-8 format.

For software developers connecting their applications to SAP HANA databases using ODBC connection, a full list of connection properties and their usage can be found at SAP HANA Client Interface Programming Reference documentation.

Then execute the same SQL query using Linked Server to access remote SAP HANA database to test if error is resolved by recent changes.

declare @SQLHANA varchar(max) = 'SELECT .... '
exec (@SQLHANA) AT HANAB1P

Code

Now the SQL query is executed and returns data successfully as seen in following screenshot. The character causing SQL error is possibly the marked characters with red.

conversion from data type VARCHAR1 to ASCII

I hope adding the ODBC connection property "CHAR_AS_UTF8" solves "Conversion of parameter/column from data type VARCHAR1 to ASCII failed" errors.

在linux下也是同样的,在 odbc.ini里面加下面一行:

char_as_utf8 = true

  • 22
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值