I’m trying to get the SqlDependency object to work with geography data, but I haven’t found any information about it online.
What geography functions work within the query notification system, and is there any way for me to get query notifications for something like this?
SELECT Id
FROM dbo.Items
WHERE
(geography::STGeomFromText(<Insert Geo Coords here>, 4326).STIntersects(Geography) = 1
AND (FullText like '%Pepsi%' OR FullText like '%Coke%'))
I want to be notified when a new row is added where the Geography field is a point that is located inside a predefined region.
The regions I have are in the form of:
'POLYGON ((-84.54674 33.647809, -84.54674 33.887618, -84.289389 33.887618, -84.289389 33.647809, -84.54674 33.647809))'
Where that would be Atlanta, GA.
The restrictions are described in Creating a Query for Notification. There is no mention of the CLR system types (
geography,geometry,hierachyid). I have described before how Query Notifications works behind the scenes and if you read that article you’ll see that the requirements for Query Notifications match exactly the requirements for indexed views (and the article explains why that is no coincidence). So if you can create an indexed view like you desire, Query Notification should work. Lets try, using the MSDN example:There’s you answer: Query Notifications (and all the other derivatives, like SqlDependency) will not work with
geography::STGeomFromTextfunction.