步骤(以SUSE为例连接SQL server 2008,其他linux版本步骤类似):
1、先确定需要下载的ODBC版本,注:需要对应系统版本及数据库版本,去微软官网查看:
下图是微软官网给出的兼容性视图:
2、ODBC历史版本下载位置:
历史版本下载:Windows 上的 ODBC Driver for SQL Server 发行说明 - ODBC Driver for SQL Server | Microsoft Docs
3、根据SAP note开始给系统安装ODBC
- note 1644499 (The Linux ODBC driver and the LIB_DBSL dbmssslib.so component are currently only available for the Linux x86_64 platform.)
- 执行如下命令:
sudo su
curl -O https://packages.microsoft.com/keys/microsoft.asc
rpm --import microsoft.asc
#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version
#SUSE Linux Enterprise Server 11 SP4
#Ensure SUSE Linux Enterprise 11 Security Module has been installed
zypper ar https://packages.microsoft.com/config/sles/11/prod.repo
#SUSE Linux Enterprise Server 12
zypper ar https://packages.microsoft.com/config/sles/12/prod.repo
#SUSE Linux Enterprise Server 15
zypper ar https://packages.microsoft.com/config/sles/15/prod.repo
#(Only for driver 17.3 and below)
SUSEConnect -p sle-module-legacy/15/x86_64
exit
sudo ACCEPT_EULA=Y zypper install -y msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y zypper install -y mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo zypper install -y unixODBC-devel
- Create necessary symlinks
# ln -s /usr/lib64/libodbc.so.2.0.0 /usr/lib64/libodbc.so.1
# ln -s /usr/lib64/libodbcinst.so.2.0.0 /usr/lib64/libodbcinst.so.1 - Additional information:
根据下列指令测试ODBC是否安装成功:
After the installation it can be checked by running the command
odbcinst -q -d -n "ODBC Driver 17 for SQL Server"
Or
odbcinst -q -d -n "ODBC Driver 13 for SQL Server"
The output should look similar to:
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1
Also, if you installed the mssql-tools package the sqlcmd utility should be able to connect to a SQL Server with a command like this:
sqlcmd –S<server_name> -U<username> –P<password>
4、sap侧配置:
- tcode:dbco
- 按照下图进行对应的配置:
5、测试连接
1、事务代码SE38 程序名ADBC_TEST_CONNECTION
2、找到配置的DB连接:
3、返回连接成功