title: Does this mySQL "spatial" query work in SQL Server 2008 as well?
body: <p>Before I embark on a a pretty decent overhaul of my web app to use a spatial query, I'd like to know if this MySQL query works in SQL Server 2008:</p>
  
  <pre><code>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 &lt; 25 
  ORDER BY distance LIMIT 0 , 20;
  </code></pre>
  
  <p><strong>Or is there a better way to do this in SQL Server 2008?</strong></p>
  
  <p>My database currently stores that lat/long of businesses near military bases in Japan. However, I'm querying the table to find businesses that contain the specified bases' id.</p>
  
  <pre><code>Biz table
  ----------------------
  PK BizId bigint (auto increment)
  Name
  Address
  Lat
  Long
  **FK BaseId int (from the MilBase table)**
  </code></pre>
  
  <p>A spatial query, based on having a center lat/long and given radius (in km) would be a better fit for the app and would open up some new possibilities.</p>
  
  <p>Any help is greatly appreciated!</p>