<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Denis Gobo : geography, geospatial</title><link>http://sqlblog.com/blogs/denis_gobo/archive/tags/geography/geospatial/default.aspx</link><description>Tags: geography, geospatial</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>SQL Server Proximity Search</title><link>http://sqlblog.com/blogs/denis_gobo/archive/2009/02/11/11843.aspx</link><pubDate>Thu, 12 Feb 2009 02:28:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11843</guid><dc:creator>Denis Gobo</dc:creator><slash:comments>1</slash:comments><comments>http://sqlblog.com/blogs/denis_gobo/comments/11843.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/denis_gobo/commentrss.aspx?PostID=11843</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/denis_gobo/rsscomments.aspx?PostID=11843</wfw:comment><description>&lt;p&gt;George, a good friend of mine created a blog post showing how you can do a &lt;a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-zipcode-latitude-longitude-pr"&gt;SQL Server Zipcode Latitude/Longitude proximity distance search&lt;/a&gt; without using the geography data type. I searched the internet to see if anyone had something similar with the geography data type available in 2008 and could not find anything that showed some useful stuff. Yes there is a lot available with geometry and polygons but nothing I was looking for. George challenged me and I did the 2008 version.&lt;/p&gt;&lt;p&gt;&amp;nbsp;There is nothing really complicated. if you run this&lt;/p&gt;&lt;div style="display:block;" class="tsql" id="cb13504"&gt;&lt;div style="border-left:medium none;" class="li1"&gt;&lt;span&gt;DECLARE&lt;/span&gt; @g geography;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li2"&gt;&lt;span&gt;DECLARE&lt;/span&gt; @h geography;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;&lt;span&gt;SET&lt;/span&gt; @h = geography::STGeomFromText&lt;span&gt;(&lt;/span&gt;&lt;span&gt;'POINT(-77.36750 38.98390)'&lt;/span&gt;, &lt;span&gt;4326&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li2"&gt;&lt;span&gt;SET&lt;/span&gt; @g = geography::STGeomFromText&lt;span&gt;(&lt;/span&gt;&lt;span&gt;'POINT(-77.36160 38.85570)'&lt;/span&gt;, &lt;span&gt;4326&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;&lt;span&gt;SELECT&lt;/span&gt; @g.&lt;span&gt;STDistance&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;@h&lt;span&gt;)&lt;/span&gt;/&lt;span&gt;1609.344&lt;/span&gt;;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;&amp;nbsp;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;You will see that the distance in miles between those two points is 8.8490611480890067&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;&amp;nbsp;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;In the end the code runs between 15 and 60 millisecond to get all the zipcodes within 20 miles of zipcode 10028, pretty impressive if you ask me&amp;nbsp; &lt;br&gt;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;&amp;nbsp;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;All the code including sample data for all the zip codes in the US can be found here &lt;/div&gt;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;&lt;a href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-2008-proximity-search-with-th"&gt;SQL Server 2008 Proximity Search With The Geography Data Type&lt;/a&gt; &lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;&amp;nbsp;&lt;/div&gt;&lt;div style="border-left:medium none;" class="li1"&gt;The reason I did not post it here is because George created the 2000 version so it would be weird if the 2008 version was somewhere else, but no worries I will have a post here tomorrow about "what do you wish you knew when you were starting?"&amp;nbsp; Michelle Ufford (aka &lt;a href="http://sqlfool.com/"&gt;SQLFool&lt;/a&gt;) tagged me so look forward to that &lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=11843" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/denis_gobo/archive/tags/geography/default.aspx">geography</category><category domain="http://sqlblog.com/blogs/denis_gobo/archive/tags/geospatial/default.aspx">geospatial</category><category domain="http://sqlblog.com/blogs/denis_gobo/archive/tags/SQL+Server+2008/default.aspx">SQL Server 2008</category></item></channel></rss>