Geographic Information Systems Asked on September 15, 2020
I am working with spatial data stored in an MSSQL 2012 database as varbinary. I am able to view the spatial data in SSMS with the following query:
SELECT geometry::STGeomFromWKB([column_name], 4955) FROM table_name;
How can I view this data in QGIS? I have successfully connected to the database in QGIS and have tried to run a similar spatialite sql query on the table as a virtual layer, but it does not work.
I have also tried to add the table to the geometry_columns table. QGIS will recognize it as a spatial layer once I drag the table in from the database, but nothing renders. It still shows up as a nonspatial table in the MSSQL connection.
A user with a similar question created a view in MSSQL, but reported that it could not be imported to QGIS.
In SSMS the records look like ‘0x001110310…’etc., and in QGIS they are all ‘BLOB’.
I was able to create a view in sql server using the following:
CREATE VIEW new_table
AS
SELECT ObjID,
geometry::STGeomFromWKB([column_name], 4955) AS geom
FROM table_name
And it showed up in my MSSQL connection in QGIS as a spatial layer.
Correct answer by Andrew on September 15, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP