Reputation: 873
I have a SLES12-SP5 docker container running and I followed the instructions here : https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#suse17 to install mssql-tools.
When i try running mssql-tools, I get the following error:
c1dd384365b5:/ # /opt/mssql-tools/bin/sqlcmd
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Driver's SQLAllocHandle on SQL_HANDLE_HENV failed.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Can't initiate unicode conversion.
Is there a setting I am missing?
Upvotes: 4
Views: 1471
Reputation: 585
So to potentially save some random Googler a lot of time and research...
The Microsoft ODBC driver uses glibc gconv to convert character sets. However there is no dependency on the package and the driver simply fails with the error "[Microsoft][ODBC Driver 17 for SQL Server]Unicode conversion failed
", if the necessary gconv modules are not installed!
On some operating systems, the glibc
package already contains all the necessary gconv modules to convert from the typical character sets, however on other operating systems only ANSI C UTF-8 support is built-in and the other gconv modules are provided by the glibc-gconv-extra
package.
TL;DR the fix is install glibc-gconv-extra
.
This could be considered a bug in the Microsoft ODBC driver because of the missing dependency, however it's true that change in the packages is relatively recent.
Upvotes: 1
Reputation: 181
Make sure the package glibc-locale
is installed. You can also check the output of the locale
command.
Before:
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
...
After:
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
...
Upvotes: 2
Reputation: 4095
You can get this error if the driver does not exist on the deployment machine or there are problems with its installation.
Install/Reinstall the Microsoft ODBC Driver 17 for SQL Server ODBC Driver
Official Microsoft Download link (Windows, Linux, OSX): https://www.microsoft.com/en-us/download/details.aspx?id=56567
Documentation https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver15
Upvotes: 1