3

I'm having an issue with viewing data in QGIS 2 based on a spatial query in SQL Server 2008 R2.

The data appears to load, polygons appear and I can add thematic shading based on data.

However when I view the attribute table for the layer in QGIS, it seems like the same value is being replicated over and over again.

QGIS Data Screengrab

If I add labels, only one label appears despite there being multiple features with different attributes in the original SQL Spatial query.

QGIS Labels Screengrab

When I export the layer to a shapefile and open it in QGIS, all the data appears correctly and labelling works without any problem.

enter image description here

Why is the layer imported from SQL Server behaving so strangely?

4

QGIS must have a unique key column in order to track features. If you are missing that you will get this behavior.

You can do something like this for your view:

SELECT ROW_NUMBER() OVER(ORDER BY SalesYTD DESC) AS Row, MS0A01CD, count 
  • Ah thanks! The MSOA01CD field is unique but I see that the key must be numeric. – Tumbledown Dec 19 '13 at 12:51
  • Yes only numeric keys at the moment. – Nathan W Dec 19 '13 at 13:01

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.