[GIS] Why does QGIS recognize the geometry type of some MSSQL tables and not others

geometryqgissql serversridtable

In QGIS, when I go to add a MSSQL table, it recognizes the geometry type and SRID of some tables and not others. When it doesn't recognize these I can set them manually and load the data without a problem.

What do I have to set within SQL Server to have QGIS recognize the geometry type and I have not selected the option "Only look in the geometry_columns_metadata table" for the MSSQL connection?

enter image description here

Best Answer

QGIS reads MSSQL with a native provider which reads geometrytypes and other metadata from a table named "geometry_columns" if such exists in the database. The source code of the provider is at https://github.com/qgis/QGIS/tree/57dc3c7eff2337411c163222a4e5b7562fffd457/src/providers/mssql

The part of code that takes care of metadata is /qgsmssqlsourceselect.cpp

For making QGIS to recognize the geometry type automatically you must register the table by adding the necessary information into the "geometry_columns table". Some more information can be found from http://planet.qgis.org/planet/tag/ms%20sql%20spatial/

Related Question