Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 SQL Server 2008空间数据选择查询_Sql Server 2008_Spatial Query - Fatal编程技术网

Sql server 2008 SQL Server 2008空间数据选择查询

Sql server 2008 SQL Server 2008空间数据选择查询,sql-server-2008,spatial-query,Sql Server 2008,Spatial Query,我正在从事一个维护SQL数据库的项目。在这个数据库中,我有一个名为AirportZone的表,它的属性名为“area”,类型为geometry。此外,我还维护了一个表offerquest,其中有一个名为“location”的属性,类型为geography。由于我想知道是否有报价发生在机场区域,因此我想定义一个复杂的SQL查询,它将返回某个区域内用户发出的所有请求。比如: select OfferRequest.offer_id from OfferRequest, AirportZone wh

我正在从事一个维护SQL数据库的项目。在这个数据库中,我有一个名为AirportZone的表,它的属性名为“area”,类型为geometry。此外,我还维护了一个表offerquest,其中有一个名为“location”的属性,类型为geography。由于我想知道是否有报价发生在机场区域,因此我想定义一个复杂的SQL查询,它将返回某个区域内用户发出的所有请求。比如:

select OfferRequest.offer_id from OfferRequest, AirportZone 
where @tmp_geo is geography::STGeomFromText(CAST(AirportZone.area as varchar(max)), 4326)
and @tmp_geo.STIntersects(OfferRequest.location) = 1 and AirportZone.name = 'given_name'
显然,这个查询是错误的,因为变量@tmp_geo(我希望它的类型是geography)。有没有办法做到这一点,或者我应该定义一个while循环


谢谢

上述查询可以实现为:

DECLARE @tmp_geo geometry;
SET @tmp_geo = geography::STGeomFromText(CAST(AirportZone.area as varchar(max));
SELECT OfferRequest.offer_id FROM OfferRequest, AirportZone WHERE
@tmp_geo.STIntersects(OfferRequest.location) = 1 AND AirportZone.name = 'given_name';