Uncategorized

Linux ODBC SQL Server Driver Install

The procedure outlined below will allow you to configure a Linux machine, to connect to a Microsoft SQL Server machine using an ODBC driver.

The main goal here was to ensure the BCP ( Bulk Copy ) command can be called from a client machine loading data using the bulk insert command into the SQL Server.
Reference material

BCP documentation :

https://msdn.microsoft.com/enus/library/hh568446(v=sql.110).aspx

UnixODBC Driver Install :

https://msdn.microsoft.com/enus/library/hh568449(v=sql.110).aspx

ODBC Driver Install :

https://msdn.microsoft.com/enus/library/hh568454(v=sql.110).aspx

Media
Driver Manager :

http://www.unixodbc.org/download.html ( be sure to download 2.3.0)

ODBC Driver

https://www.microsoft.com/en-us/download/details.aspx?id=36437

Install the Unix Driver Manager ( as root user )

• Download both unixODBC-2.3.0.tar.gz and msodbcsql-11.0.2270.0.tar.gz to /tmp
• Unpack msodbcsql-11.0.2270.0.tar.gz
• cd /tmp/msodbcsql-11.0.2270.0
• Verify you need to install unixODBC via ” ./install.sh verify”
• Build the driver manager via : ./build_dm.sh –download-url=file://unixODBC-2.3.0.tar.gz
• Respond YES to build
• If build is successful install via : cd /tmp/unixODBC.11364.13163.8152/unixODBC-2.3.0
• Then : make install
• Now verify again i.e.cd /tmp/msodbcsql-11.0.2270.0, THEN ./install.sh verify, hopefully the unixODBC is now installed… proceed with ODBC Driver install
Install the ODBC Driver ( as root user )
• Install via : cd /tmp/msodbcsql-11.0.2270.0
• ./install.sh install
• Tab to the end type : YES <enter>

Once installed, should now see the following confirming it’s all installed
Enter YES to accept the license or anything else to terminate the installation: YES

Checking for 64 bit Linux compatible OS ……OK
Checking required libs are installed ……………… OK
unixODBC utilities (odbc_config and odbcinst) installed …….. OK
unixODBC Driver Manager version 2.3.0 installed ……………… OK
unixODBC Driver Manager configuration correct ……………….. OK*
Microsoft ODBC Driver 11 for SQL Server already installed …NOT FOUND
Microsoft ODBC Driver 11 for SQL Server files copied ……… OK
Symbolic links for bcp and sqlcmd created ……………… OK
Microsoft ODBC Driver 11 for SQL Server registered ……… INSTALLED
Install log created at /tmp/msodbcsql.26015.17511.20018/install.log.

Test Steps, to verify Client side BCP command is working as expected

bcp <databasename>.<schema>.<tablename> in bulkload.txt -t ‘\t’ -r ‘\n’ -U <username> -S SQLSERVER_Host -P Password -f <formatfile.fmt>

The prompt should return with result as follows :-

Starting copy…
10 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 6 Average : (1666.7 rows per sec.)

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *