I have QGIS 2.12.3 app installed on one server (servername1) and MSSQL server database installed on servername2. The database is password protected and I have made connection successfully using QGIS function to Add MSSQL spatial layer. I want to add non-spatial views to QGIS and then make joins with spatial data layers. Problem is that some views I can add, and some I can not. The message I got from QGIS is:sql= is an invalid layer and cannot be loaded. I tried to use phyton script to add layers, but it doesn't help:
uri = MSSQL:server=servername2;database='LCSPI_test_2016';tables=vw_LCZAJ_KIS_GIS_Anagrafi2;trusted_connection=yes" qgis.utils.iface.addVectorLayer(uri,'vw_LCZAJ_KIS_GIS_Anagrafi2','ogr')
I have also tried to insert in phyton script username and password of the database but nothing.
When I make all this on my computer (restore the same database, instal QGIS) I can add problematic views using Phyton script and trusted connection (so layers are ok, not invalid). Does anyone know what can be a problem?