2

I am attempting to do a join in QGIS between a SQL Server Spatial table and a non-spatial table (on a single integer field). I was able to add both successfully and make the join, but the query builder dialog only shows the fields from the spatial table.

I also tried setting a feature filter on the non-spatial table before joining to the spatial table, but that filter was not honored (no error, but no affect on the layer).

QGIS version: 2.12.1-Lyon QGIS code revision: 16760fd

Microsoft SQL Server 2012 - 11.0.2100.60 (X64) Feb 10 2012 19:39:15 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)

  • would loading the non-spatial table into MSSQL be out of the question / workflow? – DPSSpatial Dec 21 '15 at 17:37
  • The non-spatial table IS an MSSQL table. For environments where I can, I just build a spatial view that does the filtering that I need. But for other environments and/or users w/ limited privs, can the filtering be done with the software? – Jay Cummins Dec 21 '15 at 17:43
  • Try saving your joined layer as a shapefile in order to save all columns in a proper file? Joining tables in QGIS is a temporary process that often need saving into a new file to be able to work with all columns, including the joined ones. – wiltomap Dec 22 '15 at 8:48
1

I found these 2 feature requests which seem to confirm that you can't filter the layer on the joined table. The workaround is to export the layer to shapefile as @wiltomap suggested (provided the data is static).

Not possible to define subset of layer using field from joined table

query / filter on attribute tables with external tables joined

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.