[GIS] How to configure a connection to MS SQL Server from QGIS 2.18 on Linux

linuxqgissql server

I am attempting to connect to an MS SQL Server Database from QGIS 2.18 on running on Ubuntu 16.04.

I receive this error when clicking on the "List Databases". The login is a SQL Server login (not an active directory login), so it should be straight forward.

Are there additional packages that have to be installed in order for QGIS to form the connection to SQL Server?

enter image description here


OS Version:

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:    16.04
Codename:   xenial

QGIS Version:

QGIS version
2.18.13
QGIS code revision
8cba0bb
Compiled against Qt
4.8.7
Running against Qt
4.8.7
Compiled against GDAL/OGR
1.11.3
Running against GDAL/OGR
1.11.3
Compiled against GEOS
3.5.0-CAPI-1.9.0
Running against GEOS
3.5.0-CAPI-1.9.0 r4084
PostgreSQL Client Version
9.5.2
SpatiaLite Version
4.3.0a
QWT Version
5.2.3
PROJ.4 Version
492
QScintilla2 Version
2.9.1


SQL Server: 2014

Best Answer

I'll start with some info, hoping someone else can fill in the gaps.

It seems Microsoft offers an installation solution:

https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server

(I couldn't get this to work...)

Or, you need to install the unixODBC drivers.

Here is a place to start:

http://help.interfaceware.com/kb/904

I've gotten fairly far with this, in that I was able to run a TSQL select on a table in our MSSQL Server database.

The QGIS documentation doesn't acknowledge the need for an additional driver that doesn't come with Linux distros: http://docs.qgis.org/2.8/en/docs/user_manual/working_with_vector/supported_data.html#mssql-spatial-layers

I don't know how to get QGIS to recognize these drivers, however, which is where I hope someone else can fill in the gaps!

Related Question