odbc db link to MSSQL

  • From: Jeff Chirco <backseatdba@xxxxxxxxx>
  • To: oracle-l-freelist <oracle-l@xxxxxxxxxxxxx>
  • Date: Mon, 30 Jul 2018 09:51:24 -0700

Anybody have success with getting ODBC driver for SQL Server installed on
Oracle Linux 7 and getting a database link to work from 12.2

When I run a select over the db link I get this error.

ORA-28500: connection from ORACLE to a non-Oracle system returned this
message:

ORA-02063: preceding line from TESTMSSQL

I didn't try the easysoft driver cause didn't want to have to buy a driver
for this. But if it is needed I will explore that option.

I installed unixODBC 2.3.6 from http://www.unixodbc.org



# remove any existing unixODBC drivers - be very careful with 'sudo rm'!

sudo rm /usr/lib64/libodbc*



# install the unixODBC driver

# note, adding "--enable-stats=no" here is not specified by Microsoft

export CPPFLAGS="-DSIZEOF_LONG_INT=8"

./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc
--enable-gui=no --enable-drivers=no --enable-iconv
--with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE --enable-stats=no
1> configure_std.log 2> configure_err.log

make 1> make_std.log 2> make_err.log

sudo make install 1> makeinstall_std.log 2> makeinstall_err.log



# the Microsoft driver expects unixODBC to be here /usr/lib64/libodbc.so.1,

# so add soft links to the '.so.2' files

cd /usr/lib64

sudo ln -s libodbccr.so.2   libodbccr.so.1

sudo ln -s libodbcinst.so.2 libodbcinst.so.1

sudo ln -s libodbc.so.2     libodbc.so.1



Then I downloaded Microsoft ODBC Driver 17 from
https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017

sudo su

#Download appropriate package for the OS version

#Choose only ONE of the following, corresponding to your OS version

#RedHat Enterprise Server 7

curl https://packages.microsoft.com/config/rhel/7/prod.repo ;>
/etc/yum.repos.d/mssql-release.repo



exit

sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts

sudo ACCEPT_EULA=Y yum install msodbcsql17





My /etc/odbc.ini looks like this

[testmssql]

Driver=ODBC Driver 17 for SQL Server

Server=server_foo

User=test

Password=password

Database=mydb

Port=1433



/etc/odbcinst.ini

[ODBC Driver 17 for SQL Server]

Description=Microsoft ODBC Driver 17 for SQL Server

Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1

UsageCount=1



From Oracle I create a database link as

create database link testmssql connect to test identified by password using
‘testmssql’;





I am very confused how to troubleshoot this.


Any help or if you have your own notes would be helpful.

Other related posts: