sql server - how do I join against a geographic point and a geometry polygon -


i have sql server 2008 engine. in database have 2 tables. table has pk1 column, , geography data type used point value. table b has pk2 column geometric data type used polygon value. need output table c columns pk1 , pk2. populate table, need set select join geographic point in geometric polygon.

i have tried query:

select p.propertyid    ,p.parcelid    ,t.geoid [bhdev].[dbo].[ref_tracts] t join bhdev.dbo.propertyparameters p on p.geolocation.stintersects(t.geom)=1 

this results in following error: operand type clash: sys.geometry incompatible sys.geography

how join work? thanks

the clue in error text:

operand type clash: sys.geometry incompatible sys.geography

(emphasis mine) guess [bhdev].[dbo].[ref_tracts].geom geometry type column instead of geography should be. you're going have convert like:

geography::point([bhdev].[dbo].[ref_tracts].geom.x,      [bhdev].[dbo].[ref_tracts].geom.y,      3426 ) 

(or switch x & y, depending on 1 stored latitude in) , suggestion convert rows adding new column table, doing conversion above, adjusting code references geom column reference new column, , rename old column else. once have no code breaks after rename, drop column completely.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -