<div dir="ltr">never mind I figured it out.<div>I needed to add an objectid field to the view using row-number() as described here:</div><div><a href="https://gis.stackexchange.com/questions/327701/viewing-mssql-data-in-qgis">https://gis.stackexchange.com/questions/327701/viewing-mssql-data-in-qgis</a><br></div><div><br></div><div>the first line looks like </div><div>SELECT        ROW_NUMBER() OVER (ORDER BY c.Hole_ID ASC) AS OBJECTID, C.Hole_ID, </div><div><br></div><div>cheers</div><div>Damien</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 14, 2023 at 10:55 AM damien stephens <<a href="mailto:damien.stephens@gmail.com">damien.stephens@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi All;</div><div>I am having trouble bringing a geospatial  sql view into qgis using the add  mssql  server layer dialogue.<br></div><div><br></div>I have a geospatial view that was created from two tables in a separate database.<div>One of the two tables has a geospatial field. This table can be brought into qgis without issues using the add mssql server layer dialogue</div><div>The combined view can be viewed spatially in server management studio with no errors.</div><div>I can see the view in the mssql server layer dialogue and it displays as a spatial table.</div><div>However when I try to filter the layer nothing happens, ie the filter dialogue does not appear.</div><div>When i try to add the layer without filtering i get the following error:</div><div><p style="margin:0px;white-space:pre-wrap">dbname='dbase' service='dbase' user='user' password='pasword' srid=28351 type=Point disableInvalidGeometryHandling='1' primaryKeyInGeometryColumns='0' table="dbo"."view" (SP_geometry) is an invalid layer - not loaded</p></div><div>I connect to the sql server using sql server authentication, which I have checked the password etc for several times and is correct.</div><div>I can also open the view via the add vector layer - database odbc route as a non spatial table.</div><div><br></div><div>I assume that I am missing a step to make the geospatial aspect of the view compatible with qgis?</div><div><br></div><div>Any assistance would be greatly appreciated.</div><div>sincerely</div><div>Damien</div><div><br></div></div>
</blockquote></div>