QGIS 3.28, MS SQL Server 2016, EPSG:25832

I'm trying to open a view from a MSSQL database. It works ok, until I include columns that contain the WKT expression of the geometry, or the area of polygons.

The WKT string is made using SP_GEOMETRY.STAsText() and the area is calculated like this: round(SP_GEOMETRY.STArea()/10000,1) as areal_HA

Without these columns, QGIS loads the view without problems, 320 lines with all values correctly. But when I include the to columns by altering the view in MS SQL Management Studio, I only get one single row in the table in QGIS, though I can see all the polygons in the map. If I use the "Identify features" tool to look into the features in the map, then QGIS freezes.

In Management Studio, the view performs flawlessly...

Any ideas?

  • Please Edit the Question to contain more information: The coordinate reference used in your table and whether you have validated your geometries.
    – Vince
    Commented Dec 15, 2022 at 14:17
  • sorry forgot the coordinate system. geometries works great when i load the view without the two attributes.. Commented Dec 15, 2022 at 14:26
  • testet geometries in database with STIsValid(), all geometries is ok ... Commented Dec 15, 2022 at 14:32

1 Answer 1


Looks like casting the columns to nvarchar and decimal solved the problem.

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.