2

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
  • Microsoft doesn't make Linux drivers, which is the reason Linux ArcGIS Server nodes can't access SQL Server enterprise geodatabases. – Vince Nov 5 '17 at 13:39
  • 1
    @Vince these are Linux drivers from Microsoft, aren't they? docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/… – DPSSpatial Nov 6 '17 at 17:08
  • He was probably referring to native drivers. But I would have expected native drivers now that SQL Server can be installed on linux (which I've done). Of course, it could be they exist but aren't backwards compatible w/ SQL Server 2014. – Jay Cummins Nov 6 '17 at 17:56
  • Yes, native drivers (which is ironic, since Sybase started on Sun). I stopped paying attention to SQL Server years ago now. Lack of drivers wasn't the only reason; more of a symptom of the general problem of platform hostility. – Vince Nov 6 '17 at 23:42
  • I am having the same problem connecting to SQL Server on localhost in QGIS. Did you ever resolve this issue? – Cliff Dec 15 '18 at 12:05
3

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!

  • Have you tried doing it through Add vector layer option? From there you can create an OGR database connection. I haven't got a linux install so I can't test it. There was also a comment on this answer that may be a clue – MickyT Nov 7 '17 at 19:47
  • @MickyT I actually found that getspatial.com post - the error is "Can't open lib 'SQL Server' : file not found" - not sure if this method still relies on libraries that don't come by default with QGIS on Linux... thoughts? – DPSSpatial Nov 7 '17 at 20:26
  • I think I read somewhere that the ogr plugin has it's own odbc drivers, but can't find it now. I might need to find some tin to try a few things on. – MickyT Nov 7 '17 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.