与SQL Server 2008中的STContains类似的功能

时间:2013-01-15 18:31:17

标签: sql-server-2008 sql-server-2012

由于名为STContains的地理空间函数仅在SQL Server 2012中可用,因此我可以使用类似的函数在SQL Sever 2008中获得相同或类似的结果吗?

STIntersects是否可行?

干杯!

1 个答案:

答案 0 :(得分:2)

SQL Server 2008中提供了

STContains IS

DECLARE @s0 AS GEOMETRY = 'POLYGON((4 4, 7 4, 7 7, 4 7 ,4 4))'
DECLARE @s1 AS GEOMETRY = 'POLYGON((5 4.2, 6 4.2, 6 5, 5 5, 5 4.2))'

SELECT *
 FROM (
    SELECT @s0 AS 'Geo', 'S0' as 'Labels'
    UNION ALL   SELECT @s1, 'S1'
 ) AS A
 WHERE A.Geo.STContains(@S1) = 1

See SQL-Fiddle-Demo.