1

I have:

  • a table called ABC with columns (ID, County_Name, Lat, Long) in SQL server pre-filled with the values under its respective columns, except for County_Name column which is currently null.

  • an ArcGIS SDE feature class - called US_County with columns (id, County_Name, Shape).

I am trying is call the SQL Server Spatial native STintersects() to get the county name from the US_County feature into my other non-spatial ABC table. But I can't seem to get it working.

First I add in the Shape column to the ABC table like so:

ALTER TABLE ABC 
ADD Shape AS geometry::Point(Long,Lat,4326);

Then I do the STIntersects() like so:

UPDATE ABC 
SET County_Name = a.County_Name
FROM ABC c
JOIN US_County a
ON c.Shape.STIntersects(a.shape) =1;

Was wondering if the above SQL statements is correct?

Kirk Kuykendall
  • 25,787
  • 8
  • 65
  • 153
vic
  • 43
  • 4
  • You had a tag for the ArcGIS Spatial Analyst but make no mention of using it in your question body and so I have removed it. – PolyGeo Jan 16 '20 at 23:41

1 Answers1

1

Your queries looks fine, it looks to me that maybe your layers are not in the same SRID. Double check that.

This method always returns null if the spatial reference IDs (SRIDs) of the geometry instances do not match.

docs microsoft STIntersects

cabesuon
  • 1,051
  • 6
  • 7
  • Thanks! This seems to be correct. Before I have the polygon feature class with SRID of 3857. So the two SRIDs is incorrect, was able to get it working by re-projecting the polygon feature class to SRID 4326. Seems like MS SQL server does not have SRID 3857 under sys.spatial_reference_systems ? – vic Jan 22 '20 at 06:29