The following code works, but it woefully slow:
select top 100 FooId
from dbo.Foos
where latitudelongitude.ToString() = 'POINT(0,0)'
order by FooId desc
Is there a better way to determine if a GEOGRAPHY
value has the Lat/Long of 0,0
?
Flip yo test, yo. ;)
declare @g geography = geography::STPointFromText('POINT(0 0)', 4326);
select *
from dbo.Foos
where latitudelongitude.STEquals(@g) = 1
Put another way, the query that you originally wrote wasn't SARGable. The one that I wrote is.
You can use the .Lat
and .Long
to achieve that. Something like this
SELECT TOP 100 FooId
FROM dbo.Foos
WHERE latitudelongitude.Lat = 0 AND latitudelongitude.Long = 0
ORDER BY FooId desc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With