Я попытался запустить этот код на MSSQL 2014, и он возвращает значение.
DECLARE @g geometry;
SET @g = geometry::STPointFromText('POINT (60 60)', 4326);
Select Country From [vstl].[dbo].[EEZ_1] where geom.STIntersects(@g)=1;
Результаты
Singapore
Однако, когда я попытался запустить на MSSQL 2012 и 2008R2, с тем же SQL-запросом и данными, он выдал ошибку исключения, как показано ниже.
Msg 6522, Level 16, State 1, Line 4
A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry":
System.ArgumentException: 24144: This operation cannot be completed because the instance is not valid. Use MakeValid to convert the instance to a valid instance. Note that MakeValid may cause the points of a geometry instance to shift slightly.
System.ArgumentException:
at Microsoft.SqlServer.Types.SqlGeometry.ThrowIfInvalid()
at Microsoft.SqlServer.Types.SqlGeometry.STIntersects(SqlGeometry other)
.
Кто-нибудь знает, что происходит?