【发布时间】:2010-07-05 15:38:50
【问题描述】:
在我开始对我的网络应用程序进行相当大的改造以使用空间查询之前,我想知道这个 MySQL 查询是否适用于 SQL Server 2008:
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) *
cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) *
sin( radians( lat ) ) ) ) AS distance
FROM markers HAVING distance < 25
ORDER BY distance LIMIT 0 , 20;
或者在 SQL Server 2008 中有更好的方法吗?
我的数据库目前存储日本军事基地附近的经纬度企业。但是,我正在查询该表以查找包含指定基地 id 的企业。
Biz table
----------------------
PK BizId bigint (auto increment)
Name
Address
Lat
Long
**FK BaseId int (from the MilBase table)**
基于中心纬度/经度和给定半径(以千米为单位)的空间查询将更适合该应用,并会开辟一些新的可能性。
非常感谢任何帮助!
【问题讨论】:
标签: sql sql-server-2008 stored-procedures geography