2

This is a list of 193 zip codes and their geometries that do not import in QGIS. This is a list of 193 zip codes and their geometries that do not import in QGIS.

This is a list of 999 Census Block Groups and their geometries that do import in QGIS. This is a list of 999 Census Block Groups and their geometries that do import in QGIS.

This is the Add MSSQL Layer tbl in QGIS. It shows what the table displays when I try to import them both. This is the Add MSSQL Layer tbl in QGIS. It shows what the table displays when I try to import them both.

What would cause one table to be able to import, but not the other?

I am having this problem where I can't import shapefiles from SQL to QGIS. I am using zip codes in Florida as my shapes. I wrote a query in sql to give me certain zip codes and their geometries for certain counties in FL. This was put into a new table in sql consisting of nearly 200 zip codes. When I try to import this into QGIS, it wont import. The MSSQL import table doesnt allow me to select this table. However, if I change the query to include only 20 zip codes, it will allow me to select and import the table. So does QGIS have a limit to the amount of shapes it can import? I have other tables in sql that have more than 1000 shapes and they import, but not this one of 200 zip codes.

2
  • 1
    Do you have a unique id column primary key on the table in mssql? May 8, 2015 at 5:41
  • @MortenFuglsang, I added a unique ID, i.e. assigned an individual integer value to each row. Still having the same problem, though.
    – Stephenj11
    May 11, 2015 at 12:59

2 Answers 2

1

I have also noticed that QGIS up to my current version (2.12.2) appears to have a problem loading MSSQL geometries of type "GeometryCollection", when you would expect Polygons or Multipolygons. To check if you have these, use:

SELECT GEOM.STGeometryType() FROM [yourtable]
0

I use this free software, Spatial Data Manager.
I found that it is the only free software that can load spatial data directly between the major RDBMS.
You can filter your data during the export operation.

2
  • 1
    I'll give this a shot, but why use this when QGIS has the Add MSSQL layer option?
    – Stephenj11
    May 11, 2015 at 13:00
  • 2
    Sorry, I read your question very quickly and I confused QGIS with PostGIS, thinking that the problem was to load data from MSSQL to PostGIS. Now I understand the problem. Have you checked if the geometries are correct? To do this you can use the software tools that I have indicated ("Check Geometry") or run the following SQL: SELECT COUNT(*) FROM <yourtable> WHERE <yourgeometrycol>.STIsValid() = 0
    – lele3p
    May 12, 2015 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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