SQL Server Spatial ForumAny questions related to the use of spatial data in SQL Server.© 2009 Microsoft Corporation. All rights reserved.Wed, 25 Nov 2009 15:09:40 Z264afbfa-113f-400e-b4a9-5faead328944http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/34866400-91e5-4af5-9fee-f7f369aa6a61http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/34866400-91e5-4af5-9fee-f7f369aa6a61Chris Pietschmannhttp://social.msdn.microsoft.com/Profile/en-US/?user=Chris%20PietschmannWhy No LINQ To SQL or Entity Framework Support for Spatial Data Types??!?I have a new project I'm working on and I thought this time I would use either LINQ to SQL or Entity Framework, but then I tried connecting to my database that uses SQL Spatial Data Types and neither could access fields using the SQL Spatial Data Types. This is crazy! Now instead of using either of these two awesome tools, I need to take the long road and write my own complete data access layer.<br/> <br/> I figured that Visual Studio 2010 / .NET 4 Beta 2 would support them, but no support their either.<br/> <br/> When will the SQL Spatial Data Types be supported in LINQ To SQL and/or Entity Framework??<hr class="sig">Microsoft MVP - Windows Live Platform<br/> Blog: <a href="http://pietschsoft.com">http://pietschsoft.com</a> | <a href="http://simplovation.com">Web.Maps.VE - ASP.NET AJAX Virtual Earth Server Control</a>Wed, 25 Nov 2009 13:01:37 Z2009-11-25T15:09:40Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/7204f4b5-a813-4b5b-b7f9-f1dee5ab635fhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/7204f4b5-a813-4b5b-b7f9-f1dee5ab635fIndra Y.http://social.msdn.microsoft.com/Profile/en-US/?user=Indra%20Y.Retriving Latitude and Longitude directely without callback with given a post codeHi All<br/> I am using control 6.0 for bing map. <br/> Could anyone tell me how to convert a post code into lattitude and longitude without calling callback function. Any help would be appriciate?<br/> <br/> Thanks,<br/> Indra Y.Wed, 25 Nov 2009 05:21:41 Z2009-11-25T08:19:53Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/0a38aa88-b34a-4af7-b5d1-65a24a12adc8http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/0a38aa88-b34a-4af7-b5d1-65a24a12adc8wimpy1http://social.msdn.microsoft.com/Profile/en-US/?user=wimpy1FME Workbench and the invalid geography tricksIs anyone out there using FME Workbench to import geographies in one step that overcomes the &quot;Invalid geography&quot; problems?  I have heard of people bringing the items into sql geometry format and then doing the variety of tricks to force to be valid.<br/><br/>It sure would be nice if there was a way to do this in a single step from within FME.  Since FME seems to be able to do a ton of stuff (and can be slightly more complicated than rocket science) there may be something that can be done, but is outside of my knowledge.<br/>Tue, 24 Nov 2009 22:40:24 Z2009-11-24T23:06:25Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/2fbefab6-e299-4f9f-865f-c699eb723160http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/2fbefab6-e299-4f9f-865f-c699eb723160petehitchhttp://social.msdn.microsoft.com/Profile/en-US/?user=petehitchSQL export to xml<span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> <p>I am using the following code to create an xml file.  <br/><br/>SELECT</p> </span></span></span></span><span style="font-size:x-small">make </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">AS</span></span><span style="font-size:x-small"> Make</span><span style="color:#808080;font-size:x-small"><span style="color:#808080;font-size:x-small">,</span></span><span style="font-size:x-small"> model </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">AS</span></span><span style="font-size:x-small"> Model</span><span style="color:#808080;font-size:x-small"><span style="color:#808080;font-size:x-small">,</span></span><span style="font-size:x-small"> style </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">AS</span></span><span style="font-size:x-small"> Style</span><span style="color:#808080;font-size:x-small"><span style="color:#808080;font-size:x-small">,</span></span><span style="font-size:x-small"> trim </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">AS</span></span><span style="font-size:x-small"> Trim </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">FROM</span></span><span style="font-size:x-small"> my_data </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">AS</span></span><span style="font-size:x-small"> DATA </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">FOR</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">XML</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">AUTO</span></span><span style="color:#808080;font-size:x-small"><span style="color:#808080;font-size:x-small">,</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">ROOT</span></span><span style="color:#808080;font-size:x-small"><span style="color:#808080;font-size:x-small">(</span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">'my_root'</span></span><span style="color:#808080;font-size:x-small"><span style="color:#808080;font-size:x-small">)<br/><br/><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&lt;</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">my_root</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<br/>&lt;</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">DATA</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Make</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">TOYOTA</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Model</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">LANDCRUISER</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Style</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">UTILITY</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Trim</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> /&gt;<br/>&lt;</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">DATA</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Make</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">TOYOTA</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Model</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">LANDCRUISER</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Style</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">UTILITY</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Trim</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> /&gt;<br/>&lt;</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">DATA</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Make</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">TOYOTA</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Model</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">LANDCRUISER</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Style</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">UTILITY</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Trim</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> /&gt;<br/>&lt;/</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">my_root</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<br/><br/>What I want to do is create an xml file with a sub root tag<br/><br/>&lt;<span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">my_root</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<br/></span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&lt;<span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">my_subroot</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<br/></span></span>&lt;</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">DATA</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Make</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">TOYOTA</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Model</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">LANDCRUISER</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Style</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">UTILITY</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Trim</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> /&gt;<br/>&lt;</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">DATA</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Make</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">TOYOTA</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Model</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">LANDCRUISER</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Style</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">UTILITY</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Trim</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> /&gt;<br/>&lt;</span></span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">DATA</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Make</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">TOYOTA</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Model</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">LANDCRUISER</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Style</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">UTILITY</span></span><span style="color:#000000;font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">Trim</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="color:#000000;font-size:x-small">&quot;&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> /&gt;<br/>&lt;/<span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">my_subroot</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;</span></span><br/>&lt;/<span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">my_root</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<br/><br/>Is there a clean way to send the output directly to a file?  For example:<br/><br/>SELECT * FROM myTable to c:\someFile.xml<br/><br/>Any help would be appreciated.  Thanks in advance<br/></span></span><br/></span></span></span></span></span></span>Tue, 24 Nov 2009 22:49:13 Z2009-11-24T22:49:14Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/43c59caf-d971-4698-b8e4-24aa487372a1http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/43c59caf-d971-4698-b8e4-24aa487372a1Roland Krummenacherhttp://social.msdn.microsoft.com/Profile/en-US/?user=Roland%20KrummenacherSmall benchmark with PostGIS and MS SQL-Server Spatial<p>We're doing a small performance benchmark with PostGIS and Microsoft<br/>SQL-Server Spatial.</p> <p>We took some Tiger data and are doing queries like shown below.</p> <p>Any comments about these and/or suggestions about additional queries?</p> <p>- Roland</p> <p>Syntax with curly brackets as table placeholders:</p> <p>1. Loading data and generating indices</p> <p>SELECT *<br/>INTO {dataset}<br/>FROM {original dataset}<br/>WHERE geom.STIntersects(@poly) = 1</p> <p>ALTER TABLE {dataset} <br/>ADD PRIMARY KEY CLUSTERED (ID ASC)</p> <p>CREATE SPATIAL INDEX {dataset}_sidx <br/>ON {dataset} ([geom])</p> <p><br/>2. Non-spatial selection query:</p> <p>SELECT Count(*)<br/>FROM {dataset lines} l <br/>WHERE l.roadflg='Y'</p> <p><br/>3. Spatial query I:</p> <p>a)<br/>SELECT Count(*)<br/>FROM {dataset points} p WITH(INDEX(geom_sidx))<br/>WHERE p.geom.STIntersects(@poly) = 1</p> <p>b)<br/>SELECT Count(*)<br/>FROM {dataset polygons} pg WITH(INDEX(geom_sidx))<br/>WHERE pg.geom.STIntersects(@poly) = 1</p> <p>c)<br/>SELECT Count(*)<br/>FROM {datset lines} l WITH(INDEX(geom_sidx))<br/>WHERE l.geom.STIntersects(@poly) = 1</p> <p><br/>4. Spatial query II:</p> <p>a)<br/>SELECT COUNT(*)<br/>FROM {dataset points} p WITH(INDEX(geom_sidx))<br/>WHERE p.geom.STDistance(@point) &lt;= x</p> <p>b)<br/>SELECT COUNT(*)<br/>FROM {dataset polygons} pg WITH(INDEX(geom_sidx))<br/>WHERE pg.geom.STDistance(@point) &lt;= x</p> <p>c)<br/>SELECT COUNT(*)<br/>FROM {dataset lines} l WITH(INDEX(geom_sidx))<br/>WHERE l.geom.STDistance(@point) &lt;= x</p> <p><br/>5. Join of a linestring and a polygon table</p> <p>SELECT SUM(pg.geom.STLength())<br/>FROM {dataset lines} l<br/>JOIN {dataset polygons} pg WITH(INDEX(geom_sidx)) <br/>ON l.geom.STDistance(pg.geom) &lt;= 10<br/>WHERE l.railflg = 'Y'</p>Tue, 24 Nov 2009 15:26:24 Z2009-11-24T18:28:34Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/46f89e12-a4df-4d45-8c19-b58308c40cafhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/46f89e12-a4df-4d45-8c19-b58308c40cafpowelldahttp://social.msdn.microsoft.com/Profile/en-US/?user=powelldaSpatial Index not being used.....well sometimes<p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small"><span style="font-family:Consolas">I know there have been many post on this issue, but I can't seem to find a solid answer to the problem.<span style="">  </span>We have an issue where queries coming in from ArcCatalog (ESRI application) are not using spatial indexes...most of the time.<span style="">  </span>I know this is a proprietary application, but it's not an issue with the application, it's an issue with the query optimizer.<span style="">  </span>I say this because sometimes those queries will use the spatial indexes, but most of the time it just chooses the clustered index.<span style="">  </span>We are running SQL Server 2008 SP1, and I've seen some posts saying something about this being a known issue and that Cumulative Update 3 might fix it.</span></span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Consolas"> </span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small"><span style="font-family:Consolas">I know those spatial indexes work, because I can use the Geometry methods from queries I create in SSMS, and those indexes will get used. <span style=""> </span>Also, from those queries I create I do not have to use the WITH clause.<span style="">  </span>The optimizer will choose those spatial indexes every time.<span style="">  </span>I know that the WITH clause can be used to force the index to be used, but because the queries coming in are from a third party application, I cannot use the WITH clause.<span style="">  </span></span></span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Consolas"> </span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small"><span style="font-family:Consolas">I have also tried freeing up the procedure cache, updating statistics, and recreating the spatial indexes, but this has done nothing.<span style="">  </span>At this point, I'm at a loss on how to move forward.<span style="">  </span>I have contacted ESRI about this issue, and they say it's an issue with SQL Server.<span style="">  </span>At this point I have to agree with them, because of the inconsistent performance from SQL Server. </span></span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Consolas"> </span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small"><span style="font-family:Consolas">Any assistance would be appreciated.</span></span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Consolas"> </span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small"><span style="font-family:Consolas">Thanks,</span></span></p> <p class=MsoPlainText style="margin:0in 0in 0pt"><span style="font-size:small"><span style="font-family:Consolas">Dave </span></span></p>Wed, 18 Nov 2009 19:32:55 Z2009-11-21T07:16:13Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/53096fef-4403-40bd-8d50-4b346db87e78http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/53096fef-4403-40bd-8d50-4b346db87e78pascalhhttp://social.msdn.microsoft.com/Profile/en-US/?user=pascalhGet Point of a minimum DistanceHi there,<br/><br/>I have a single point and a table which contains some geography polygons. Now, I can easily calculate which is the nearest polygon by using STDistance and sorting. Is there an easy way to get the connection point between the point and the polygon? I.e. when i walk the minimum distance from the point toward the polygon, where do i 'hit' the polygon?<br/><br/>thanks!Tue, 10 Nov 2009 10:36:39 Z2009-11-19T19:09:13Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/9c7cd2d8-71f9-4f17-84db-13c3064ccf3fhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/9c7cd2d8-71f9-4f17-84db-13c3064ccf3fDiesel Shaver Demohttp://social.msdn.microsoft.com/Profile/en-US/?user=Diesel%20Shaver%20DemoPolar Steregraphic Projections<p class=MsoNormal style="margin:0in 0in 10pt"><span style="line-height:115%;font-family:'Verdana','sans-serif';color:black;font-size:8pt">I have a large amount of data in SQL server using ESRI SDE. The data is stored in Polar Stereographic Coordinate systems (EPSG:3031 and EPSG:3995). I would like to shift from using SDE's data storage model which has the spatial storage in a binary format in a different table from the attribute data to using the SQL Server geography type. <br/><br/>But, it appears that SQL server does not support these SRIDs. I could not find anything close even in the 390 SRIDs available.<br/><br/>What are my options?</span></p>Thu, 19 Nov 2009 17:39:22 Z2009-11-24T15:35:39Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/5e5916b1-5910-432b-8e39-31b04d6490f9http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/5e5916b1-5910-432b-8e39-31b04d6490f9andriesohttp://social.msdn.microsoft.com/Profile/en-US/?user=andriesoSupport for 3D OGC Shapes planned for SQL 11?Will 3D OGC (<a href="http://www.opengeospatial.org/">http://www.opengeospatial.org/</a>) geometries (POLYGONZ, TINZ, etc) be supported in the next release of SQL Server (v11)?<br/><br/>Thanks<br/>AndriesMon, 16 Nov 2009 16:53:43 Z2009-11-18T09:21:02Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/7a4ea181-7d07-4792-a8f3-e9c13886bbafhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/7a4ea181-7d07-4792-a8f3-e9c13886bbafMichael Berthoixhttp://social.msdn.microsoft.com/Profile/en-US/?user=Michael%20BerthoixProblem of extra lines appearing when apply a buffer to a polygon with 2 points very close to each otherHello, <div><br/></div> <div>When a apply a buffer (STBuffer or BufferWithTolerance) to a polygon which has 2 points very close to each other, there a thin extra line appearing in the resulting shape. Here is a<span style="font-family:Arial;font-size:13px;white-space:pre"> simple example : </span></div> <div><span style="font-family:Arial;font-size:small"><span style="font-size:13px;white-space:pre"> <div style="color:Black;background-color:White"> <pre><span style="color:Blue">SELECT</span> geography::Parse(<span style="color:#A31515">'POLYGON ((0.148179995191816 47.6541796714871, 0.147984451614527 47.6541745060093,  <span style="color:#000000"><span style="color:#A31515">0.147964192853032 47.6541716952762, 0.147946096891203 47.6541648763069, 0.147931743821736 47.6541544837423, 0.147923079560787 47.6541417689002, 0.147920863563632 47.6541276908329, 0.147924624338343 47.654113995209, 0.147934722145717 47.6541016335643, 0.147950297425504 47.6540920743301, 0.147969315287163 47.6540862239523, 0.147989757526645 47.654084584297, 0.14818090965349 47.6540896671125, 0.148379543085387 47.6540780198092, 0.148792888566824 47.6540523274557, 0.148796486858373 47.6540522602022, 0.149078805922644 47.6540456955336, 0.149079210673302 47.6540455681842, 0.14941422307804 47.6540399941278, 0.149427379759305 47.6540406465296, 0.149672703597952 47.6540690151693, 0.149692490982198 47.6540735712802, 0.149709322879961 47.6540819857756, 0.149721231111283 47.6540935468119, 0.149727472854001 47.65410689077, 0.149726889420521 47.6541210511025, 0.149720351426794 47.6541342896428, 0.1497079033212 47.6541455275075, 0.149690787134495 47.6541537083386, 0.149671037731293 47.6541579256563, 0.149650274115975 47.6541576700538, 0.149411309184178 47.6541300958256, 0.149083093611218 47.654135527838, 0.14880317478795 47.6541420027277, 0.148391430946737 47.6541675903095, 0.148391031753409 47.6541675827962, 0.148188394934308 47.6541794246997, 0.148179995191816 47.6541796714871))'</span>) .STBuffer(5)</span></span></pre> </div> <div><br/></div> <div>The line length and the number of lines appearing in the buffered shape seems to depends on the distance of the points and the size of the buffer.</div> <div>If I remove one of the 2 very close points, there are no problem anymore.</div> <div>If I change the buffer size to 10, no problem too.</div> <div><br/></div> <div>Any suggestion to solve this problem ?</div> <div><br/></div> <div>Thanks in advance for your answers,</div> <div><br/></div> <div>BR,</div> <div><br/></div> <div><strong>Michaël Berthoix</strong></div> <div>Itelios do Brasil - São Paulo</div> <div>http://www.itelios.com.br</div> </span></span></div>Tue, 03 Nov 2009 17:52:58 Z2009-11-16T11:51:56Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/969c2138-dc73-4f18-b453-e3d81a3e1758http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/969c2138-dc73-4f18-b453-e3d81a3e1758bixb0012http://social.msdn.microsoft.com/Profile/en-US/?user=bixb0012Performance as it relates to sp_help_spatial_geometry_index output<p>While performance tuning queries and spatial indexes for a project, I have come across a situation where I cannot completely understand how the output from sp_help_spatial_geometry_index helps explain the performance difference between two extremely similar queries.  I am hoping someone in the forums can help lift the fog...<br/><br/>The code for the two queries differs by one line (the code below includes both lines with comments indicating which line belongs to which query).</p> <pre lang=x-sql>DECLARE @geom geometry DECLARE @GeomCollWKT NVARCHAR(max) SET @GeomCollWKT = (SELECT shape.STAsText() + ', ' FROM subset_geom FOR XML PATH('')) SET @GeomCollWKT = 'GEOMETRYCOLLECTION (' + LEFT(@GeomCollWKT, DATALENGTH(@GeomCollWKT)/2 - 2) + ')' SET @geom = geometry::STGeomCollFromText(@GeomCollWKT, 1) SET @geom = @geom.STUnion(@geom.STPointN(1)) -- First query, 9 seconds but with false positives SET @geom = @geom.STUnion(@geom.STPointN(1)).STBuffer(-0.002) -- Second query, 25 seconds but correct result set exec sp_help_spatial_geometry_index 'BASE_GEOM','s1_idx', 1, @geom</pre> <p>The output from sp_help_spatial_geometry_index for both queries is below (with runtimes added):</p> <table style="table-layout:fixed;width:516pt;border-collapse:collapse" border=0 cellspacing=0 cellpadding=0 width=687> <colgroup span=1><col style="width:382pt" span=1 width=509><col style="width:67pt" span=2 width=89></colgroup> <tbody> <tr style="height:15pt" height=20> <td class=xl6323986 style="width:382pt;height:15pt" width=509 height=20> </td> <td class=xl6423986 style="width:67pt" width=89>Query 1</td> <td class=xl6423986 style="width:67pt" width=89>Query 2</td> </tr> <tr style="height:15pt" height=20> <td class=xl6523986 style="height:15pt" height=20>RUNTIME (sec)</td> <td class=xl6323986 align=right>9</td> <td class=xl6323986 align=right>25</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Base_Table_Rows</td> <td class=xl6323986 align=right>67718</td> <td class=xl6323986 align=right>67718</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Bounding_Box_xmin</td> <td class=xl6323986 align=right>404902</td> <td class=xl6323986 align=right>404902</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Bounding_Box_ymin</td> <td class=xl6323986 align=right>5275715</td> <td class=xl6323986 align=right>5275715</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Bounding_Box_xmax</td> <td class=xl6323986 align=right>415914</td> <td class=xl6323986 align=right>415914</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Bounding_Box_ymax</td> <td class=xl6323986 align=right>5287908</td> <td class=xl6323986 align=right>5287908</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Grid_Size_Level_1</td> <td class=xl6323986 align=right>64</td> <td class=xl6323986 align=right>64</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Grid_Size_Level_2</td> <td class=xl6323986 align=right>64</td> <td class=xl6323986 align=right>64</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Grid_Size_Level_3</td> <td class=xl6323986 align=right>64</td> <td class=xl6323986 align=right>64</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Grid_Size_Level_4</td> <td class=xl6323986 align=right>64</td> <td class=xl6323986 align=right>64</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Cells_Per_Object</td> <td class=xl6323986 align=right>16</td> <td class=xl6323986 align=right>16</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Primary_Index_Rows</td> <td class=xl6323986 align=right>578045</td> <td class=xl6323986 align=right>578045</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Primary_Index_Pages</td> <td class=xl6323986 align=right>1723</td> <td class=xl6323986 align=right>1723</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Average_Number_Of_Index_Rows_Per_Base_Row</td> <td class=xl6323986 align=right>8</td> <td class=xl6323986 align=right>8</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_ObjectCells_In_Level0_In_Index</td> <td class=xl6323986 align=right>2</td> <td class=xl6323986 align=right>2</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_ObjectCells_In_Level1_In_Index</td> <td class=xl6323986 align=right>9</td> <td class=xl6323986 align=right>9</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_ObjectCells_In_Level2_For_QuerySample</td> <td class=xl6323986 align=right>12</td> <td class=xl6323986 align=right>12</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_ObjectCells_In_Level2_In_Index</td> <td class=xl6323986 align=right>5594</td> <td class=xl6323986 align=right>5594</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_ObjectCells_In_Level3_For_QuerySample</td> <td class=xl6323986 align=right>787</td> <td class=xl6323986 align=right>787</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_ObjectCells_In_Level3_In_Index</td> <td class=xl6323986 align=right>120448</td> <td class=xl6323986 align=right>120448</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_ObjectCells_In_Level4_For_QuerySample</td> <td class=xl6323986 align=right>225</td> <td class=xl6323986 align=right>225</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_ObjectCells_In_Level4_In_Index</td> <td class=xl6323986 align=right>451992</td> <td class=xl6323986 align=right>451992</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Interior_ObjectCells_In_Level2_For_QuerySample</td> <td class=xl6323986 align=right>12</td> <td class=xl6323986 align=right>12</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Interior_ObjectCells_In_Level2_In_Index</td> <td class=xl6323986 align=right>19</td> <td class=xl6323986 align=right>19</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Interior_ObjectCells_In_Level3_For_QuerySample</td> <td class=xl6323986 align=right>530</td> <td class=xl6323986 align=right>530</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Interior_ObjectCells_In_Level3_In_Index</td> <td class=xl6323986 align=right>3350</td> <td class=xl6323986 align=right>3350</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Interior_ObjectCells_In_Level4_For_QuerySample</td> <td class=xl6323986 align=right>131</td> <td class=xl6323986 align=right>131</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Interior_ObjectCells_In_Level4_In_Index</td> <td class=xl6323986 align=right>23216</td> <td class=xl6323986 align=right>23216</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Intersecting_ObjectCells_In_Level1_In_Index</td> <td class=xl6323986 align=right>7</td> <td class=xl6323986 align=right>7</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Intersecting_ObjectCells_In_Level2_In_Index</td> <td class=xl6323986 align=right>5268</td> <td class=xl6323986 align=right>5268</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Intersecting_ObjectCells_In_Level3_For_QuerySample</td> <td class=xl6323986 align=right>253</td> <td class=xl6323986 align=right>253</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Intersecting_ObjectCells_In_Level3_In_Index</td> <td class=xl6323986 align=right>116309</td> <td class=xl6323986 align=right>116309</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Intersecting_ObjectCells_In_Level4_For_QuerySample</td> <td class=xl6323986 align=right>11</td> <td class=xl6323986 align=right>11</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Intersecting_ObjectCells_In_Level4_In_Index</td> <td class=xl6323986 align=right>387866</td> <td class=xl6323986 align=right>387866</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Border_ObjectCells_In_Level0_In_Index</td> <td class=xl6323986 align=right>2</td> <td class=xl6323986 align=right>2</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Border_ObjectCells_In_Level1_In_Index</td> <td class=xl6323986 align=right>2</td> <td class=xl6323986 align=right>2</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Border_ObjectCells_In_Level2_In_Index</td> <td class=xl6323986 align=right>307</td> <td class=xl6323986 align=right>307</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Border_ObjectCells_In_Level3_For_QuerySample</td> <td class=xl6323986 align=right>4</td> <td class=xl6323986 align=right>4</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Border_ObjectCells_In_Level3_In_Index</td> <td class=xl6323986 align=right>789</td> <td class=xl6323986 align=right>789</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Border_ObjectCells_In_Level4_For_QuerySample</td> <td class=xl6323986 align=right>83</td> <td class=xl6323986 align=right>83</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Total_Number_Of_Border_ObjectCells_In_Level4_In_Index</td> <td class=xl6323986 align=right>40910</td> <td class=xl6323986 align=right>40910</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Interior_To_Total_Cells_Normalized_To_Leaf_Grid_Percentage</td> <td class=xl6323986 align=right>32.91457286</td> <td class=xl6323986 align=right>32.91457286</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Intersecting_To_Total_Cells_Normalized_To_Leaf_Grid_Percentage</td> <td class=xl6323986 align=right>2.763819095</td> <td class=xl6323986 align=right>2.763819095</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Border_To_Total_Cells_Normalized_To_Leaf_Grid_Percentage</td> <td class=xl6323986 align=right>64.32160804</td> <td class=xl6323986 align=right>64.32160804</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Average_Cells_Per_Object_Normalized_To_Leaf_Grid</td> <td class=xl6323986 align=right>0.005877315</td> <td class=xl6323986 align=right>0.005877315</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Average_Objects_PerLeaf_GridCell</td> <td class=xl6323986 align=right>170.1457286</td> <td class=xl6323986 align=right>170.1457286</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Number_Of_SRIDs_Found</td> <td class=xl6323986 align=right>1</td> <td class=xl6323986 align=right>1</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Width_Of_Cell_In_Level1</td> <td class=xl6323986 align=right>172.0625</td> <td class=xl6323986 align=right>172.0625</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Width_Of_Cell_In_Level2</td> <td class=xl6323986 align=right>2.688476563</td> <td class=xl6323986 align=right>2.688476563</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Width_Of_Cell_In_Level3</td> <td class=xl6323986 align=right>0.042007446</td> <td class=xl6323986 align=right>0.042007446</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Width_Of_Cell_In_Level4</td> <td class=xl6323986 align=right>0.000656366</td> <td class=xl6323986 align=right>0.000656366</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Height_Of_Cell_In_Level1</td> <td class=xl6323986 align=right>190.515625</td> <td class=xl6323986 align=right>190.515625</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Height_Of_Cell_In_Level2</td> <td class=xl6323986 align=right>2.976806641</td> <td class=xl6323986 align=right>2.976806641</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Height_Of_Cell_In_Level3</td> <td class=xl6323986 align=right>0.046512604</td> <td class=xl6323986 align=right>0.046512604</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Height_Of_Cell_In_Level4</td> <td class=xl6323986 align=right>0.000726759</td> <td class=xl6323986 align=right>0.000726759</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Area_Of_Cell_In_Level1</td> <td class=xl6323986 align=right>2097958.063</td> <td class=xl6323986 align=right>2097958.063</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Area_Of_Cell_In_Level2</td> <td class=xl6323986 align=right>32780.59473</td> <td class=xl6323986 align=right>32780.59473</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Area_Of_Cell_In_Level3</td> <td class=xl6323986 align=right>512.1967926</td> <td class=xl6323986 align=right>512.1967926</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Area_Of_Cell_In_Level4</td> <td class=xl6323986 align=right>8.003074884</td> <td class=xl6323986 align=right>8.003074884</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>CellArea_To_BoundingBoxArea_Percentage_In_Level1</td> <td class=xl6323986 align=right>1.5625</td> <td class=xl6323986 align=right>1.5625</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>CellArea_To_BoundingBoxArea_Percentage_In_Level2</td> <td class=xl6323986 align=right>0.024414063</td> <td class=xl6323986 align=right>0.024414063</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>CellArea_To_BoundingBoxArea_Percentage_In_Level3</td> <td class=xl6323986 align=right>0.00038147</td> <td class=xl6323986 align=right>0.00038147</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>CellArea_To_BoundingBoxArea_Percentage_In_Level4</td> <td class=xl6623986 align=right>5.96E-06</td> <td class=xl6623986 align=right>5.96E-06</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Number_Of_Rows_Selected_By_Primary_Filter</td> <td class=xl6323986 align=right>7315</td> <td class=xl6323986 align=right>7315</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Number_Of_Rows_Selected_By_Internal_Filter</td> <td class=xl6323986 align=right>5190</td> <td class=xl6323986 align=right>5190</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Number_Of_Times_Secondary_Filter_Is_Called</td> <td class=xl6323986 align=right>2125</td> <td class=xl6323986 align=right>2125</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Number_Of_Rows_Output</td> <td class=xl6323986 align=right>6654</td> <td class=xl6323986 align=right>6237</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Percentage_Of_Rows_NotSelected_By_Primary_Filter</td> <td class=xl6323986 align=right>89.19784991</td> <td class=xl6323986 align=right>89.19784991</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Percentage_Of_Primary_Filter_Rows_Selected_By_Internal_Filter</td> <td class=xl6323986 align=right>70.95010253</td> <td class=xl6323986 align=right>70.95010253</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Internal_Filter_Efficiency</td> <td class=xl6323986 align=right>77.99819657</td> <td class=xl6323986 align=right>83.21308321</td> </tr> <tr style="height:15pt" height=20> <td class=xl6323986 style="height:15pt" height=20>Primary_Filter_Efficiency</td> <td class=xl6323986 align=right>90.96377307</td> <td class=xl6323986 align=right>85.26315789</td> </tr> </tbody> </table> <p> The reason for the second query (the one with the extra buffer step) is that without shrinking the overlay geometry by some very small amount, the overlays I am doing return false positives.  My guess is rounding errors.<br/><br/>At this point, my primary concern is not with my approach but trying to understand how the results of sp_help_spatial_geometry_index relate to the performance difference I am seeing.  Although I would expect the queries to have some performance difference, the gap between 9 seconds and 25 seconds seems oddly large given the similar nature of the queries and similar results from the spatial index reports.<br/><br/>Does the difference boil down to simply the time it takes for the database engine to remove the 400+ extra records?  It is my understanding the number of calls to the secondary filter can strongly affect runtimes, but the calls to the secondary filter are the same for both queries.  The only real difference in the results above is the Number_Of_Rows_Output, which of course affects the Internal_Filter_Efficiency and Primary_Filter_Efficiency.<br/><br/>Am I completely missing the obvious?</p>Thu, 12 Nov 2009 17:26:16 Z2009-11-14T03:19:38Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/e1189988-8a9e-44a4-9e30-daaddde60791http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/e1189988-8a9e-44a4-9e30-daaddde60791radpinhttp://social.msdn.microsoft.com/Profile/en-US/?user=radpingroup by and stareaI've got my trusty spatial book, a few months of experience, and I'm back with what I'm guessing is a basic question.<br/><br/>I've got a table with something like this (the geography is a point):<br/><br/>ID - geography<br/><br/>1 - 0x234234<br/>2-  0x982342<br/>2-  0x763423<br/>3-  0x234523<br/>3-  0x234235<br/>3-  0x234234<br/><br/><br/>What I'd like to do is something like &quot; select ID, starea(geography) from mytable group by ID&quot;<br/><br/>I'm assuming I need to make some multipoint geographies out of the the things that have 3 or more points, then do the area off of that. Just losing my mind a bit trying to figure out the syntax or where to start.<br/><br/>I could just haul the whole mess back into C# from a query and do it in there, but I was hoping to have a query so I didn't have to haul all my data back.Fri, 13 Nov 2009 02:42:25 Z2009-11-13T23:53:15Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/3aec4b51-eeb3-4e16-8ffb-5ff2249ded0ahttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/3aec4b51-eeb3-4e16-8ffb-5ff2249ded0aBlair Suttonhttp://social.msdn.microsoft.com/Profile/en-US/?user=Blair%20Suttonhow to flatten a table of nested overlapping polygons into a table of nested non-overlapping polygonsHi<br/> <br/> I was wondering if any one else may have solved a similar problem in the past.<br/> <br/> I have a table of nested overlapping polygons and I would like to flatten this set of polygons into a table of nested <span style="text-decoration:underline">non-overlapping</span> polygons. The new table will look almost the same except when a larger polygon overlaps a smaller one then the difference is taken. The effect being that no two polygons will overlap and if a covered point is chosen you will be guaranteed to be in the smallest polygon covering the point in the original table.<br/> <br/> To add some clarity here are two table definitions showing an example source table and an example destination table.<br/> <br/> <pre lang=x-sql>declare @g1 geography = 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'; declare @g2 geography = 'POLYGON((1 1, 9 1, 9 9, 1 9, 1 1))'; declare @g3 geography = 'POLYGON((2 2, 8 2, 8 8, 2 8, 2 2))'; declare @h1 geography = 'POLYGON((20 0, 30 0, 30 10, 20 10, 20 0))'; declare @h2 geography = 'POLYGON((21 1, 29 1, 29 9, 21 9, 21 1))'; declare @h3 geography = 'POLYGON((22 2, 28 2, 28 8, 22 8, 22 2))'; declare @source table (id int identity, name varchar(max),bounds geography) insert into @source values ('g1', @g1); insert into @source values ('g2', @g2); insert into @source values ('g3', @g3); insert into @source values ('h1', @h1); insert into @source values ('h2', @h2); insert into @source values ('h3', @h3); select * from @source declare @target table (id int identity, name varchar(max),bounds geography) insert into @target values ('G1', @g1.STDifference(@g2)); insert into @target values ('G2', @g2.STDifference(@g3)); insert into @target values ('G3', @g3); insert into @target values ('H1', @h1.STDifference(@h2)); insert into @target values ('H2', @h2.STDifference(@h3)); insert into @target values ('H3', @h3); select * from @target</pre> I hoped I could use a recursive CTE but could not discover a good enough recursive member.<br/> <br/> Thanks in advance<br/> Blair <br/> <br/> <br/> <br/>Fri, 13 Nov 2009 09:11:54 Z2009-11-13T14:21:11Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/dba5711d-4738-4bab-9f0e-013e399fa59ahttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/dba5711d-4738-4bab-9f0e-013e399fa59aDan_Danhttp://social.msdn.microsoft.com/Profile/en-US/?user=Dan_DanSpatial Index on a table for best performanceHi all,<br/><br/>I have a database table that stores polygons that represent simple bounding boxes. Ocasionaly there is a point for which i would like to find a bounding box in which case it would be the point itself.<br/><br/>I have created a spatial index on the table just using the normal Create Index command on the field that stored the geometry.<br/><br/>I was wondering if this would give me the best performance or there are other better ways to do this?<br/><br/>Sincerely<br/>Dan<br/><br/><hr class="sig">DanWed, 11 Nov 2009 04:39:46 Z2009-11-19T06:56:23Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/3dcf965f-d4a5-49e3-8e57-afb95fcacf23http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/3dcf965f-d4a5-49e3-8e57-afb95fcacf23Richie_Aussiehttp://social.msdn.microsoft.com/Profile/en-US/?user=Richie_AussieSubquery or not? Hi all,<br/><br/> <div style="color:black;background-color:white"> <pre><span style="color:blue">SELECT</span> sde.FIREWARDENDISTRICTS.OBJECTID <span style="color:blue">AS</span> OID, sde.FIREWARDENDISTRICTS.NAME <span style="color:blue">AS</span> Warden, (<span style="color:blue">select</span> r.PHONE <span style="color:blue">from</span> sde.dbo.RURALAREAOFFICE r, sde.FIREWARDENDISTRICTS f <span style="color:blue">where</span> r.Shape.STIntersects(f.Shape) = 1 <span style="color:blue">group</span> <span style="color:blue">by</span> r.PHONE) <span style="color:blue">AS</span> Phone, sde.FIREWARDENDISTRICTS.Shape <span style="color:blue">FROM</span> sde.RIMSFWD_V <span style="color:blue">INNER</span> <span style="color:blue">JOIN</span> sde.FIREWARDENDISTRICTS <span style="color:blue">ON</span> sde.RIMSFWD_V.DISTRICT_NAME = sde.FIREWARDENDISTRICTS.NAME <span style="color:blue">WHERE</span> sde.RIMSFWD_V.PHONE <span style="color:blue">is</span> <span style="color:blue">null</span> <span style="color:blue">UNION</span> <span style="color:blue">ALL</span> <span style="color:blue">SELECT</span> sde.FIREWARDENDISTRICTS.OBJECTID <span style="color:blue">AS</span> OID, sde.FIREWARDENDISTRICTS.NAME <span style="color:blue">AS</span> Warden, sde.RIMSFWD_V.PHONE, sde.FIREWARDENDISTRICTS.Shape <span style="color:blue">FROM</span> sde.RIMSFWD_V <span style="color:blue">INNER</span> <span style="color:blue">JOIN</span> sde.FIREWARDENDISTRICTS <span style="color:blue">ON</span> sde.RIMSFWD_V.DISTRICT_NAME = sde.FIREWARDENDISTRICTS.NAME <span style="color:blue">WHERE</span> sde.RIMSFWD_V.PHONE <span style="color:blue">is</span> <span style="color:blue">not</span> <span style="color:blue">null</span> </pre> </div> <br/>What I'm trying to achieve is being able to include Phone numbers from my sde.dbo.RURALAREAOFFICE where they don't exist in sde.RIMSFWD_V.PHONE (only 5%). I need to do this by accessing the phone no in sde.dbo.RURALAREAOFFICE that intersect each <br/>record in my sde.firewardendistricts where the district name in the sde.rimsfwd_v matches that in the sde.firewardendistricts and where<br/>phone is null<br/><br/>I hope I've made sense?Tue, 10 Nov 2009 02:55:54 Z2009-11-12T00:25:37Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/60ef5fdb-338f-42ce-9d41-ce38760edf09http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/60ef5fdb-338f-42ce-9d41-ce38760edf09wimpy1http://social.msdn.microsoft.com/Profile/en-US/?user=wimpy1SSIS import/export does not work with spatial typesI want to move a copy of a single table from on database on a SQL2008 server to another database on another SQL2008 server.  Using the built in import/export wizard in SQL Management Studio, it complains  &quot;Found 1 unknown column type conversion(s)   You are only allowed to save the package&quot;.<br/><br/>Has anyone found a workaround for this?Tue, 05 May 2009 14:11:02 Z2009-11-06T20:56:01Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/761a942f-1ee4-40e9-b684-a31e1b46788ahttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/761a942f-1ee4-40e9-b684-a31e1b46788ageomakhshttp://social.msdn.microsoft.com/Profile/en-US/?user=geomakhsSQL Server Spatial filter optimizationHi all, <div><br/></div> <div>I have a spatial table containing 3400 parcels and correctly indexed, and when I run the following query on a far over dimensioned server, the performances are barely bad.</div> <div>This request takes <span style="font-family:Calibri, sans-serif;font-size:15px;color:#ff0000;font-weight:bold">between 1,5 and 2 seconds</span></div> <div><span style="font-family:Calibri, sans-serif;color:#ff0000;font-size:medium"><span style="font-size:15px"><strong><span style="color:#000000;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;font-weight:normal"> <p class=MsoNormal style="margin-left:72pt"><em>SELECT F.[GEOMETRY].STAsBinary() as GEOMETRY,F. ID_TRANSAC,F.ID_ENTITY,F.ID_STRUCTURE,F.ID</em></p> <p class=MsoNormal style="margin-left:72pt"><em>FROM CARTO.PG F with (INDEX([SPATIAL_PG]) )</em></p> <p class=MsoNormal style="margin-left:72pt"><em>WHERE</em></p> <p class=MsoNormal style="margin-left:72pt"><em>[GEOMETRY].Filter(geometry::STGeomFromText('POLYGON ((242353.225061205 2093829.3626259, 442712.156613794 2093829.3626259, 442712.156613794 2212891.8626259, 242353.225061205 2212891.8626259, 242353.225061205 2093829.3626259))', 0))=1</em></p> <p class=MsoNormal style="margin-left:72pt"><em>AND</em></p> <p class=MsoNormal style="margin-left:72pt"><em>[GEOMETRY].MakeValid().STEnvelope().STIntersects(geometry::STGeomFromText('POLYGON ((242353.225061205 2093829.3626259, 442712.156613794 2093829.3626259, 442712.156613794 2212891.8626259, 242353.225061205 2212891.8626259, 242353.225061205 2093829.3626259))', 0))=1</em></p> <p class=MsoNormal style="margin-left:72pt"><em></em></p> </span></strong></span></span></div> <div><span style="font-family:Calibri, sans-serif;color:#ff0000;font-size:medium"><span style="font-size:15px"><strong><span style="color:#000000;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;font-weight:normal"> <div>If I remove the second part of my WHERE, <span style="font-style:italic">[GEOMETRY].MakeValid().STEnvelope().STIntersects<span style="font-style:normal">, I get the same results, but a bit faster (<span style="font-family:Calibri, sans-serif;font-size:15px;color:#ff0000;font-weight:bold">between 0,4 and 0,6 seconds<span style="color:#000000;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;font-weight:normal">).</span></span></span></span></div> <div>If I remove the function <span style="font-style:italic">[GEOMETRY].STAsBinary() <span style="font-style:normal">in the select, the response comes even a bit faster (<span style="font-family:Calibri, sans-serif;font-size:15px;color:#ff0000;font-weight:bold"><span style="color:#000000;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;font-weight:normal"><strong><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:red">between 0,3 and 0,5 seconds</span></strong>)</span></span></span></span></div> <div><br/></div> <div>Is there a way to optimize the data / indexation / DB parameters, to make the functions <span style="font-style:italic">[GEOMETRY].MakeValid().STEnvelope().STIntersects<span style="font-style:normal"> and <span style="font-style:italic">[GEOMETRY].STAsBinary() <span style="font-style:normal">perfectly tuned ?</span></span></span></span></div> <div>Isn't the second part of my where <span style="font-style:italic">[GEOMETRY].MakeValid().STEnvelope().STIntersects <span style="font-style:normal">clause supposed to improve my overall performance ?</span></span></div> <div><br/></div> <div>Thanks a lot,</div> <div><br/></div> <div>Geomakhs.</div> </span></strong></span></span></div>Wed, 04 Nov 2009 20:01:07 Z2009-11-16T09:45:38Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/328068ea-1f48-4e80-b093-5b1bd0506a94http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/328068ea-1f48-4e80-b093-5b1bd0506a94chris portyhttp://social.msdn.microsoft.com/Profile/en-US/?user=chris%20portySupport for storing arc in SQL Server 2008 R2 available????Hi,<br/><br/>I know there is no support in for storing arcs in SQL Server 2008. Does anybody know if it is possible in the upcoming Release 2008 R2?<br/>Or does anybody know when this feature will be available?<br/><br/>Thanks for the help.<br/><br/>Chris<br/>Mon, 02 Nov 2009 15:53:01 Z2009-11-02T21:09:09Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/8e792fe5-d1fe-4d51-b495-7566618ff374http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/8e792fe5-d1fe-4d51-b495-7566618ff374ChrisMapperhttp://social.msdn.microsoft.com/Profile/en-US/?user=ChrisMapperDataTable.Load(IDataReader) fails on geography columnI have some code like the following that fills a DataTable using an arbitrary select command.  But when the reader contains a column with geography datatype I get the exception seen below:<br/><br/><span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">SqlCommand</span></span><span style="font-size:x-small"> cmd = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">new</span></span><span style="font-size:x-small"> </span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">SqlCommand</span></span><span style="font-size:x-small">(command, conn);<br/></span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">SqlDataReader</span></span><span style="font-size:x-small"> reader = cmd.ExecuteReader();<br/></span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">DataTable</span></span><span style="font-size:x-small"> table = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">new</span></span><span style="font-size:x-small"> </span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">DataTable</span></span><span style="font-size:x-small">();<br/>table.Load(reader);<br/><br/>Unhandled Exception: System.Data.DataException: Type 'Microsoft.SqlServer.Types.SqlGeometry, Microsoft.SqlServer.Types, Version=10.0.0.0, Cu<br/>lture=neutral, PublicKeyToken=89845dcd8080cc91' does not implement IComparable interface. Comparison cannot be done.<br/>   at System.Data.Common.SqlUdtStorage.CompareValueTo(Int32 recordNo1, Object value)<br/>   at System.Data.Index.CompareRecords(Int32 record1, Int32 record2)<br/>   at System.Data.RBTree`1.RBInsert(Int32 root_id, Int32 x_id, Int32 mainTreeNodeID, Int32 position, Boolean append)<br/>   at System.Data.Index.InitRecords(IFilter filter)<br/>   at System.Data.Index..ctor(DataTable table, IndexField[] indexFields, DataViewRowState recordStates, IFilter rowFilter)<br/>   at System.Data.DataTable.GetIndex(IndexField[] indexDesc, DataViewRowState recordStates, IFilter rowFilter)<br/>   at System.Data.DataColumn.get_SortIndex()<br/>   at System.Data.DataColumn.IsNotAllowDBNullViolated()<br/>   at System.Data.DataTable.EnableConstraints()<br/>   at System.Data.DataTable.set_EnforceConstraints(Boolean value)<br/>   at System.Data.DataTable.EndLoadData()<br/>   at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, I<br/>nt32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)<br/>   at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)<br/>   at System.Data.Common.LoadAdapter.FillFromReader(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)<br/>   at System.Data.DataTable.Load(IDataReader reader, LoadOption loadOption, FillErrorEventHandler errorHandler)<br/><br/>However, if I use an SqlDataAdapter instead of an SqlDataReader then I am able to successfully fill a DataTable with my results when they contain a geography column:<br/><br/><span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">SqlCommand</span></span><span style="font-size:x-small"> cmd = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">new</span></span><span style="font-size:x-small"> </span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">SqlCommand</span></span><span style="font-size:x-small">(command, conn);<br/></span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">DataTable</span></span><span style="font-size:x-small"> table = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">new</span></span><span style="font-size:x-small"> </span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">DataTable</span></span><span style="font-size:x-small">();<br/></span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">SqlDataAdapter</span></span><span style="font-size:x-small"> adapter = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">new</span></span><span style="font-size:x-small"> </span><span style="color:#2b91af;font-size:x-small"><span style="color:#2b91af;font-size:x-small">SqlDataAdapter</span></span><span style="font-size:x-small">(cmd);<br/>adapter.Fill(table);<font size=2> <p>What's the difference here?  The problelm is that I already have a lot of code that passes around SqlDataReader objects, and it would be a lot of work (and testing) to replace it with SqlDataAdapter.  Can I somehow fill a DataTable using a SqlDataReader when the result set contains UDT's?</p> </font></span></p> <p> </p> </span></p>Mon, 21 Sep 2009 18:46:15 Z2009-11-02T03:08:35Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/62cfe732-d881-4234-98d0-e0c406d55f82http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/62cfe732-d881-4234-98d0-e0c406d55f82Ali_DBAhttp://social.msdn.microsoft.com/Profile/en-US/?user=Ali_DBAKML DATA TYPESHello Experts <div><br/></div> <div>Our company is starting a new project, in which the KML data is loaded in compressed format into sql server. This KML data is used by a web server to give out the required info..(which is address) to the user. </div> <div><br/></div> <div>I have many questions with regards to this..</div> <div><br/></div> <div>1. Is it possible to load the compressed format of the KML data into SQL Server</div> <div>2. When the web server grabs the data from the sql server, how can it change the digitized data into user understandable language.</div> <div><br/></div> <div>Can someone throw light on this?</div> <div><br/></div> <div>Thanks</div> <div>ALI DBA</div>Wed, 28 Oct 2009 18:02:06 Z2009-10-30T17:38:12Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/008cc162-78ba-497a-a317-81c84009b8a6http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/008cc162-78ba-497a-a317-81c84009b8a6Tek_Timhttp://social.msdn.microsoft.com/Profile/en-US/?user=Tek_TimIs SQL Spatial supported in Compact Framework 3.5 and Sql CE 3.5 SP1?Is SQL Spatial supported in Compact Framework 3.5  and Sql CE 3.5 SP1?Mon, 26 Oct 2009 20:14:16 Z2009-10-29T14:49:49Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/61f2bd03-3a03-4ba9-be98-473ed196ed66http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/61f2bd03-3a03-4ba9-be98-473ed196ed66Tek_Timhttp://social.msdn.microsoft.com/Profile/en-US/?user=Tek_TimHow to create SQL Geography type in C#Hello,<br/> <br/> How do I create a geography type point using C#. I am looking for some examples, blogs etc for compact framework. I was looking at :<br/> http://jasonfollas.com/blog/archive/2008/12/11/using-ado.net-with-sql-server-spatial-objects.aspx but there are 2 problems-<br/> <br/> 1) If I add Microsoft.SqlServer.Types in my windows mobile project as a reference and debug, the project starts deploying 20 different dlls like system.web etc onto device and the app folder becomes huge in size and device runs out of memory. Is there a CF version of this dll that I can add as a reference?<br/> <br/> 2) There is no property for UDTName for sqlceParameter<br/> <br/> I would really appreciate if someone can help me out with this!<br/> Thanks<br/> Apurva<br/>Fri, 23 Oct 2009 20:28:27 Z2009-10-30T11:41:41Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/c2308cd5-a392-493f-82c6-7015229958b9http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/c2308cd5-a392-493f-82c6-7015229958b9Rosemary Juddhttp://social.msdn.microsoft.com/Profile/en-US/?user=Rosemary%20JuddChecking if a point intersects within a 3d polygonHello, <br/><br/>I have read the &quot;Beginning Spatial with SQL server 2008&quot; and checked on the web, but I cannot find anyway how to do the following inside the DB. So I am not sure if it can even be done.<br/><br/>What I am trying to find a way that for a given point(x,y,z) does it intersect/contain within a 3D polygon. I know I can do it in 2D, which I have tried and it works fine. <br/><br/>So the actual problem I am trying to solve is -<br/>I want to store in the DB polygons that reperesnt layers, so each layer will have a depth and then I can say for a xyz point it will be in this layer.. <br/>Is this possible?<br/><br/>Any help would be greatly appretiated<br/><br/>Thank you <br/>RosemaryFri, 23 Oct 2009 03:41:37 Z2009-10-27T10:24:04Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/25721182-36e7-414e-95f1-44765aea5765http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/25721182-36e7-414e-95f1-44765aea5765CaptainFrankhttp://social.msdn.microsoft.com/Profile/en-US/?user=CaptainFrankPolygon shadingHow are polygons shaded using values from other columns in table?  For example, there are 4788 polygons representing census block groups, where each polygon will have a color, pattern or gradient based on one of four nominal catagories.<br/><br/>Thanks in advanceTue, 20 Oct 2009 05:38:03 Z2009-10-22T19:32:34Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/c616a983-c177-4da2-a90e-afd79a254733http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/c616a983-c177-4da2-a90e-afd79a254733CaptainFrankhttp://social.msdn.microsoft.com/Profile/en-US/?user=CaptainFrankHow do I view more than 1000 rows in spatial results pane using geometry spatial data in Sql server 2008I want to show complete spatial results.  When I execute a query with spatial data, geography based spatial data returns all rows as points, but using the same data as geometry will show only up to 1000 rows.  All rows are returned in the query results pane in either case.<br/><br/>How do I show more than 1000 rows in query spatial results pane using geometry spatial data?Sun, 18 Oct 2009 14:54:38 Z2009-10-21T13:34:11Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/12a6d58e-35b6-4147-923a-53eddd456314http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/12a6d58e-35b6-4147-923a-53eddd456314Roquerohttp://social.msdn.microsoft.com/Profile/en-US/?user=RoqueroSolving STUnion rounding problemHi,<br/><br/>I'm trying to join 3 LineStrings that I know connect and will form a single LineString. But STUnion thinks it is a MultiLineString, since it does some rounding error when doing the operation. I'll guess is not a real bug, but an effect of complex geometry-operations? <br/><br/>I'm thinking of implementing my own STUnion for LineString, that simply appends points from the second LineString to the first LineString. Is there a better alternative?<br/><br/>Thanks in advance<br/><br/>/Tommy<br/>Mon, 19 Oct 2009 18:43:53 Z2009-10-20T10:09:31Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/54e669b3-61dc-4ba7-b63c-f42fc3def2e4http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/54e669b3-61dc-4ba7-b63c-f42fc3def2e4MHabibhttp://social.msdn.microsoft.com/Profile/en-US/?user=MHabibHow to Convert geometry xsd to .net class and consume via web service?<p>I need a way to represent the objects in <a href="http://schemas.opengis.net/gml/3.1.1/base/geometryBasic0d1d.xsd">http://schemas.opengis.net/gml/3.1.1/base/geometryBasic0d1d.xsd</a> (especially the pointType) in .net and be able to return them from a webservice call.<br/><br/>The problem is that, according to the xsd, the Point can be an array of doubles. XSD.exe generates code like below. Unfortunately the array of doubles (any array other than string) cannot be serialized in xml. I have tried the techniques from <a href="http://webservices20.blogspot.com/2009/04/opengis-with-net-20-and-wcf.html">http://webservices20.blogspot.com/2009/04/opengis-with-net-20-and-wcf.html</a> that uses an alternative xsd where the generated vb code becomes array of objects. <br/></p> <p>&lt;System.Xml.Serialization.XmlTypeAttribute([Namespace]:=<span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">&quot;http://www.opengis.net/gml&quot;</span></span><span style="font-size:x-small">), _<font size=2> <p>System.Xml.Serialization.XmlRootAttribute(</p> </font></span></p> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">&quot;pos&quot;</span></span><span style="font-size:x-small">, [Namespace]:=</span><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">&quot;http://www.opengis.net/gml&quot;</span></span><span style="font-size:x-small">, IsNullable:=</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">False</span></span><span style="font-size:x-small">)&gt; _<font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Public</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Class</span></span><span style="font-size:x-small"> DirectPositionType<font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Private</span></span><span style="font-size:x-small"> textField() </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Double <p> </p> </span></span></p> <span style="font-size:x-small"> <p>&lt;System.Xml.Serialization.XmlTextAttribute()&gt; _</p> <font size=2> <p> </p> </font></span> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Public</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Property</span></span><span style="font-size:x-small"> Text() </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Double</span></span><span style="font-size:x-small">()<font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Get</span></span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Return</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Me</span></span><span style="font-size:x-small">.textField<font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">End</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Get</span></span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Set</span></span><span style="font-size:x-small">(</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">ByVal</span></span><span style="font-size:x-small"> value </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">As</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Double</span></span><span style="font-size:x-small">())<font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Me</span></span><span style="font-size:x-small">.textField = value<font size=2> <p> </p> </font></span></p> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">End</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Set</span></span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">End</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Property</span></span></p> <span style="font-size:x-small"><font size=2> <p> </p> </font></span> <p><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">End</span></span><span style="font-size:x-small"> </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Class<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p> </p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><br/><br/>I appreciate the help.</p>Tue, 20 Oct 2009 00:19:12 Z2009-10-20T00:19:13Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/b74fccfb-5170-40f9-a0ea-c501d9d43431http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/b74fccfb-5170-40f9-a0ea-c501d9d43431Peter DiTurihttp://social.msdn.microsoft.com/Profile/en-US/?user=Peter%20DiTuriPoint-In-Polygon Stored Procedure: Using Parameters and MIsmatched Data TypesI'm trying to write a stored procedure that will accept a long/lat, locate it in a polygon layer, and return an attribute value for the polygon.&nbsp; I have been able to write T-SQL which does the trick, but I can get a stored procedure that will work correctly.<br /><br />I've narrowed down the culprit to this inconsistency.&nbsp; In T-SQL, this code:<br /><br /><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;"><font size="2" color="#0000ff"><font size="2" color="#0000ff"> <p>&nbsp;</p> </font></font></span><font size="2" color="#0000ff"> <p>&nbsp;</p> </font></span> <p><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">select</span></span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">geography</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">::</span></span><span style="font-size: x-small;">Parse</span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">(</span></span><span style="font-size: x-small; color: #ff0000;"><span style="font-size: x-small; color: #ff0000;">'POINT(-122.362 47.533)'</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">)<br /><br />gives me a different result from:<br /><br /><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">declare</span></span><span style="font-size: x-small;"> @longitude </span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">numeric</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">=-</span></span><span style="font-size: x-small;">122.362<br /></span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">declare</span></span><span style="font-size: x-small;"> @latitude </span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">numeric</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">=</span></span><span style="font-size: x-small;"> 47.533<br /><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">select</span></span><span style="font-size: x-small; color: #000000;"> </span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">geography</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">::</span></span><span style="font-size: x-small; color: #000000;">Parse</span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">(</span></span><span style="font-size: x-small; color: #ff0000;"><span style="font-size: x-small; color: #ff0000;">'POINT('</span></span><span style="font-size: x-small; color: #000000;"> </span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">+</span></span><span style="font-size: x-small; color: #000000;"> </span><span style="font-size: x-small; color: #ff00ff;"><span style="font-size: x-small; color: #ff00ff;">CAST</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">(</span></span><span style="font-size: x-small; color: #000000;">@longitude </span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">AS</span></span><span style="font-size: x-small; color: #000000;"> </span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">VARCHAR</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">)</span></span><span style="font-size: x-small; color: #000000;"> </span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">+</span></span><span style="font-size: x-small; color: #000000;"> </span><span style="font-size: x-small; color: #ff0000;"><span style="font-size: x-small; color: #ff0000;">' '</span></span><span style="font-size: x-small; color: #000000;"> </span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">+</span></span><span style="font-size: x-small;"><span style="color: #000000;"> </span></span><span style="font-size: x-small; color: #ff00ff;"><span style="font-size: x-small; color: #ff00ff;">CAST</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">(</span></span><span style="font-size: x-small;">@latitude </span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">AS</span></span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #0000ff;"><span style="font-size: x-small; color: #0000ff;">VARCHAR</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">)</span></span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">+</span></span><span style="font-size: x-small;"> </span><span style="font-size: x-small; color: #ff0000;"><span style="font-size: x-small; color: #ff0000;">')'</span></span><span style="font-size: x-small; color: #808080;"><span style="font-size: x-small; color: #808080;">)<br /></span></span></span><br />I'm not sure how to overcome this issue.&nbsp; I thought that local parameters would behave well, but it looks liek CASTing isn't the answer.&nbsp; Do I need to do&nbsp;a workaround for this?&nbsp; Please help!<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...pete..<br /><br /></span></span></p>Fri, 02 Oct 2009 20:14:32 Z2009-10-16T21:59:37Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/01aa47ff-f122-4d16-af73-6a0e6816d5edhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/01aa47ff-f122-4d16-af73-6a0e6816d5edMaxi Nghttp://social.msdn.microsoft.com/Profile/en-US/?user=Maxi%20NgError 6517 when trying to create Spatial Index<p>It said something like the domain administrator of the server cannot be created, I don't know if that is the correct translation.<br />Error code is 6517.<br /><br />I have a table with a column which datatype is geography.<br />I am trying to build an index on it. I am using this to store location on earth. will convert back to WGS84 later.<br /><br />I add the column to the index key column grid, and select index type as spatial.<br />then I go to the spatial page and set the tessellation scheme to geography grid.<br /><br />I click ok and this error is encountered. Please help.</p>Wed, 14 Oct 2009 10:22:40 Z2009-10-20T06:07:10Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/3a9c2ae8-c5e1-4fe0-b27d-d80b0b7c5f99http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/3a9c2ae8-c5e1-4fe0-b27d-d80b0b7c5f99shekihanhttp://social.msdn.microsoft.com/Profile/en-US/?user=shekihanSpatial Data - finding all cities in the coridorHi,<br /><br />I have a Cities geo data table with Lat and Long columns in it. I want to find all cities which fit into the 50 miles coridor&nbsp;between City1 and City2 (say Seattle to LA).<br />What is the best way to do it? Thanks.Tue, 13 Oct 2009 22:42:16 Z2009-10-15T19:08:19Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/75ae7c17-25db-4586-b9da-68f5f6810273http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/75ae7c17-25db-4586-b9da-68f5f6810273Henrrymxdfhttp://social.msdn.microsoft.com/Profile/en-US/?user=HenrrymxdfSQL Server 2005 linked to SQL Server 2008 with Geospatial DatatypesHi<br /><br />I am trying to create a Linked Server in SQL 2005 to a SQL 2008.<br /><br />&nbsp;First i created the linked server using the SQL Server Manager but when i run a query the following message appears<br /><strong><br />OLE DB provider "SQLNCLI" for linked server "servergeo" returned message "Invalid character value for cast specification".<br />OLE DB provider "SQLNCLI" for linked server "servergeo" returned message "Invalid character value for cast specification".<br />Msg 7330, Level 16, State 2, Line 1<br />Cannot fetch a row from OLE DB provider "SQLNCLI" for linked server "servergeo".</strong><br /><br />I also create the linked server using the next sentences <br /><br />exec sp_addlinkedserver 'servergeo', '', 'SQLNCLI', NULL, NULL, 'SERVER=192.168.1.,1434', NULL <br />exec sp_addlinkedsrvlogin 'servergeo', 'false', NULL, 'sa', 'xxxxxx'&nbsp; <br /><br />also got the same message.<br /><br />please somebody ???<br />Mon, 19 Jan 2009 20:11:02 Z2009-11-03T22:42:10Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/2c31fc92-33ed-435a-a357-b6f9b152bac7http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/2c31fc92-33ed-435a-a357-b6f9b152bac7Rakesh 5645http://social.msdn.microsoft.com/Profile/en-US/?user=Rakesh%205645Converting Postcode to Lat Long and Vice VersaHello All,<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; There are 2 new datatypes Geometry and Geography in SQL Server 2008. Geometry is primarily for 2D applications, distance calulating, drawing polygons etc. I wanted to know how we can use Geography Datatype.<br /> <br /> Apart from using Geography datatype in Virtual earth application are there any functions available using which we can store locations based on latitude/longitude using Geography datatype and change postcodes to lat long and vice versa.<br /> <br /> <br /> <br /> Thanks in Advance<br /> <br /> RakeshFri, 09 Oct 2009 06:57:32 Z2009-10-13T14:35:02Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/01e5c428-8959-479e-abf7-b5d505887b46http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/01e5c428-8959-479e-abf7-b5d505887b46Hubert-Associateshttp://social.msdn.microsoft.com/Profile/en-US/?user=Hubert-AssociatesSqlSpatial: Can it be true? No LINQ!Hi. I was referred to this forum as the best place to ask this. At first I thought I was doing something wrong -- and I still may be -- but maybe I can get some tips here.<br><br>Situation: I have tables in SQL Server 2008 that store map info using standard SQL Server 2005 data types and my C# geo-app uses LINQ to access  tables/data, often via an light-ORM-layer generated by Microsoft SqlMetal. Well, I've added the cool SQL spatial types to my tables, and as soon as I did. <br><br>1. SqlMetal warns me that it is dropping the fields:<br>&quot;Warning : SQM1021: Unable to extract column '_Area_Polygon_UDT' of Table 'dbo.rc_Resources' from SqlServer because the column's DbType is a user-defined type (UDT).&quot;<br><br>2. Visual Studio 2008 SP1 Object To Relational Designer / Entity Builder will no longer let me visualize/edit/include tables into the workarea because they now contain an unsupported data type.<br><br>Does anybody know how to leverage the spatial UDTs using C#/LINQ even if I have to modify or create access code by hand (in the DB or in C#).<br><br>I sure hope that I'm missing out on something :-)<br><br>Thanks!<br><br>Richard<br> <hr class=sig>Hubert-AssociatesThu, 26 Feb 2009 07:01:17 Z2009-10-12T19:24:15Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/44e547bf-047d-454c-9a72-57a15a1b2dffhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/44e547bf-047d-454c-9a72-57a15a1b2dffwimpy1http://social.msdn.microsoft.com/Profile/en-US/?user=wimpy1How to get a hemisphere with specified point as the center?Imagine looking at a round globe.&nbsp; You can only see one "hemisphere" and the center point would be the middle of the visible area.&nbsp;The other hemisphere would not be visible because it would be on the "back" of the globe relative to your observation point.<br /><br />Is there a way to create a SQL2008 geography polygon object that corresponds to the "visible" side, centered on a specified lat/long?Fri, 09 Oct 2009 20:01:55 Z2009-10-10T11:31:40Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/ff306e32-35c1-4015-9eb1-f187738febd1http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/ff306e32-35c1-4015-9eb1-f187738febd1erick.thompsonhttp://social.msdn.microsoft.com/Profile/en-US/?user=erick.thompsonWithout SqlServer.Types in Silverlight, what is the best way to work with WKB?I am using ADO.NET Data Services, which uses Entity Framework, which in turn does not understand the spatial types. As a result, I always convert my spatial types to WKB in order to use them in the Entity Framework (they show up as binary data). However, I am now working on a Silverlight Project, and the SqlServer.Types assembly isn't in Silverlight (which I hope will be changed soon!). In the meantime, is anyone aware of another way to work with WKB data in Silverlight?<br /><br />Thanks,<br />ErickMon, 05 Oct 2009 03:25:27 Z2009-10-13T02:29:30Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/c2b2a3ea-4801-405f-a2be-f843afcb816ehttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/c2b2a3ea-4801-405f-a2be-f843afcb816eAviationPlanninghttp://social.msdn.microsoft.com/Profile/en-US/?user=AviationPlanningPlease Recompile SqlServer.Types for SilverlightIt would be very helpful to recompile the geo types so they can be used in Silverlight.  Right now the workaround is to convert the geo types to a path geo string on the server and then send to Silverlight and decode.Mon, 23 Mar 2009 04:22:55 Z2009-10-05T20:33:31Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/cf1c6844-58c1-4a91-8057-7785ca7efc31http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/cf1c6844-58c1-4a91-8057-7785ca7efc31Peter Khttp://social.msdn.microsoft.com/Profile/en-US/?user=Peter%20KGetting Geography type to work with Virtual Earth Silverlight control<p>Not sure if this is the right forum for this but here goes: <br/><br/>Is there any way I can create a Silverlight Virtual Earth MapPolygon from a field i pull from geography typed column in SQL Server? I need to be able to read the string representation of the polygon. I can either use .AsTextZM() or .AsGml() NOT the binary geography format.  Example String returned from SQL Server:</p> <p style="font-size:8">GEOMETRYCOLLECTION (POLYGON ((90.519439697265625 22.685829162597656, 90.68359375 22.853885650634766, 90.469917297363281 22.867288589477539, 90.519439697265625 22.685829162597656)), LINESTRING (91.40277099609375 22.498050689697266, 91.513046264648438 22.345550537109375), POLYGON ((91.027206420898438 22.083885192871094, 91.174697875976563 22.218605041503906, 91.089706420898438 22.524024963378906, 91.027206420898438 22.083885192871094)), LINESTRING (90.6107406616211 22.161661148071289, 90.517486572265625 21.988048553466797), POLYGON ((90.671371459960937 21.987216949462891, 90.878860473632813 22.436660766601563, 90.662483215332031 22.783193588256836, 90.671371459960937 21.987216949462891)), POLYGON ((91.886932373046875 21.47332763671875, 91.978317260742188 21.642772674560547, 91.845954895019531 21.704160690307617, 91.886932373046875 21.47332763671875)), POLYGON ((92.327110290527344 20.744819641113281, 92.260818481445313 21.414440155029297, 92.669342041015625 21.296981811523438, 92.278045654296875 23.71082878112793, 91.9585952758789 23.727771759033203, 91.81817626953125 23.090274810791016, 91.61151123046875 22.944578170776367, 91.42608642578125 23.261943817138672, 91.344291687011719 23.098190307617188, 91.16192626953125 23.631525039672852, 91.3819808959961 24.105134963989258, 91.882575988769531 24.151556015014648, 92.117202758789063 24.389995574951172, 92.248382568359375 24.89457893371582, 92.491630554199219 24.877510070800781, 92.03887939453125 25.1874942779541, 89.850540161132812 25.288955688476563, 89.733940124511719 26.156314849853516, 89.319908142089844 26.024829864501953, 89.070732116699219 26.38532829284668, 88.857147216796875 26.240140914916992, 88.413070678710938 26.626140594482422, 88.335586547851563 26.482997894287109, 88.523063659667969 26.3673152923584, 88.182891845703125 26.150550842285156, 88.11053466796875 25.835552215576172, 89.0086669921875 25.290275573730469, 88.4542236328125 25.188398361206055, 88.043869018554688 24.685203552246094, 88.742080688476562 24.241668701171875, 88.565963745117188 23.646661758422852, 88.786338806152344 23.492841720581055, 88.727134704589844 23.247077941894531, 88.982795715332031 23.206140518188477, 88.863105773925781 22.968257904052734, 89.063003540039063 22.115474700927734, 89.244979858398438 21.642843246459961, 89.35498046875 21.966035842895508, 89.462760925292969 21.768886566162109, 89.4747085571289 22.289163589477539, 89.528251647949219 21.990690231323242, 89.615119934082031 22.319580078125, 89.581100463867188 21.70166015625, 89.883735656738281 21.8946475982666, 90 22.48375129699707, 89.915817260742188 22.037220001220703, 90.238449096679688 22.182842254638672, 90.0233154296875 21.863468170166016, 90.269989013671875 21.846940994262695, 90.401382446289062 22.260555267333984, 90.435951232910156 22.073051452636719, 90.612480163574219 22.302776336669922, 90.424400329589844 22.77018928527832, 90.6131820678711 23.218328475952148, 90.308868408203125 23.414440155029297, 90.548042297363281 23.384302139282227, 90.593826293945313 23.597965240478516, 90.8315200805664 22.688327789306641, 91.230674743652344 22.586385726928711, 91.455825805664063 22.789997100830078, 91.6583251953125 22.554164886474609, 92.327110290527344 20.744819641113281)))<br/></p>Mon, 21 Sep 2009 14:54:45 Z2009-10-05T17:01:22Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/a56a3603-3364-45f6-88f0-940d9cc3df34http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/a56a3603-3364-45f6-88f0-940d9cc3df34Eugene Ostroukhovhttp://social.msdn.microsoft.com/Profile/en-US/?user=Eugene%20OstroukhovAggregating GeographyHello! <div><br/></div> <div>Im trying to aggregate some geography objects (polygons).</div> <div>Here`s two ways to do it:</div> <div><br/></div> <div><br/></div> <div><strong>1) T-SQL :</strong></div> <div><br/></div> <div><br/></div> <div> <div style="color:Black;background-color:White"> <pre><span style="color:Blue">declare</span> @g geography <span style="color:Green">-- just first row from the table for example</span> <span style="color:Blue">select</span> @g = geoinfo <span style="color:Blue">from</span> border <span style="color:Blue">where</span> VID = 3688 <span style="color:Blue">select</span> @g = @g.STUnion(b.geoinfo) <span style="color:Blue">from</span> border b <span style="color:Blue">where</span> b.VID &lt; 3900 <span style="color:Blue">select</span> @g </pre> </div> <div><br/></div> <div><br/></div> <strong> 2) Creating .NET assembly and aggregate:</strong></div> <div><br/></div> <div><br/></div> <div><br/></div> <div> <div style="color:Black;background-color:White"> <pre><span style="color:Blue">namespace</span> SqlGeoTools { [Serializable, StructLayout(LayoutKind.Sequential), SqlUserDefinedAggregate(Format.UserDefined, IsInvariantToDuplicates = <span style="color:Blue">true</span>, IsInvariantToNulls = <span style="color:Blue">true</span>, IsInvariantToOrder = <span style="color:Blue">true</span>, IsNullIfEmpty = <span style="color:Blue">false</span>, MaxByteSize = -1)] <span style="color:Blue">public</span> <span style="color:Blue">class</span> GeoUnion : IBinarySerialize { <span style="color:Blue">private</span> SqlGeography val; <span style="color:Blue">public</span> <span style="color:Blue">void</span> Init() { val = <span style="color:Blue">new</span> SqlGeography(); } <span style="color:Blue">public</span> <span style="color:Blue">void</span> Accumulate(SqlGeography Value) { <span style="color:Blue">if</span> (val == <span style="color:Blue">null</span>) val = <span style="color:Blue">new</span> SqlGeography(); <span style="color:Blue">if</span> (!Value.IsNull) val = val.STUnion(Value); } <span style="color:Blue">public</span> <span style="color:Blue">void</span> Merge(GeoUnion Group) { val = val.STUnion(Group.val); } <span style="color:Blue">public</span> SqlGeography Terminate() { <span style="color:Blue">return</span> val; } <span style="color:Blue">public</span> <span style="color:Blue">void</span> Read(System.IO.BinaryReader r) { <span style="color:Blue">if</span> (val == <span style="color:Blue">null</span>) val = <span style="color:Blue">new</span> SqlGeography(); <span style="color:Blue">this</span>.val.Read(r); } <span style="color:Blue">public</span> <span style="color:Blue">void</span> Write(System.IO.BinaryWriter w) { <span style="color:Blue">if</span> (val == <span style="color:Blue">null</span>) val = <span style="color:Blue">new</span> SqlGeography(); val.Write(w); } } } </pre> </div> with</div> <div> <div style="color:Black;background-color:White"> <pre>sp_configure <span style="color:#A31515">'clr enabled'</span>, 1 go <span style="color:Blue">reconfigure</span> go <span style="color:Blue">create</span> <span style="color:Blue">assembly</span> SQLGeoTools <span style="color:Blue">from</span> <span style="color:#A31515">'D:\pr\sqlGeography\SqlGeoFunctions\bin\Debug\SqlGeoFunctions.dll'</span> go <span style="color:Blue">create</span> <span style="color:Blue">aggregate</span> GeographyUnion(@geog geography) <span style="color:Blue">returns</span> geography <span style="color:Blue">external</span> <span style="color:Blue">name</span> SqlGeoTools.[SqlGeoTools.GeoUnion] </pre> </div> </div> <div>Anything is fine until I want to aggregate too many objects.</div> <div>The script takes about two minutes to complete for 1000 geo objects.</div> <div>2k objects - cant wait so long. :(</div> <div><br/></div> <div>How can I improve my code / server settings / smth else ? </div> <div><br/></div> <div><br/></div> <div><br/></div>Tue, 22 Sep 2009 05:37:24 Z2009-10-05T07:22:03Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/db1e2c17-71b5-4bce-a166-dae4b576d653http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/db1e2c17-71b5-4bce-a166-dae4b576d653Kevin from Seattlehttp://social.msdn.microsoft.com/Profile/en-US/?user=Kevin%20from%20SeattleQuery Plan ignores spatial index without a hintHello all,<br/>I've reviewed a number of similar questions on this forum (and learned alot!) but still would like to post my question. Despite meeting the criteria set out in Bob Beauchemin's post at <a href="http://www.sqlskills.com/BLOGS/BOBB/category/SQL-Server-Spatial.aspx#p9">http://www.sqlskills.com/BLOGS/BOBB/category/SQL-Server-Spatial.aspx#p9</a> , I cannot induce the query plan to grab the index without a hint. <br/><br/>As suggested in Bob's blog post, the sql instance is SP1, i'm using the correct syntax, the join is simple (though it does have two OUTER JOINS to reference tables). I'm passing in a geography variable, using sp_executesql,  using the correct syntax for the STintersects function, and I spent a fair amount of time finding a well performing spatial index. <br/><br/>With an index hint, and with FORCESEEK, i can drop a query time from ~12 seconds to ~1 second. Without the hint but with FORCESEEK, it comes in at about 7 seconds.<br/><br/>Also I find that using sp_executesql within the stored procedure helps performance significantly.<br/><br/>One other intriguing thing to note: I had this query running at sub second times for a while. Then I changed the index hint to reference a different spatial index, and the performance tanked. I looked at the query plan and noted it was different. So I changed the procedure back to referencing the previous index, but the performance didn't return, and the query plan didn't return either. My guess is that for a while the query optimizer was choosing one of several plans, and the one it chose rocked. But it wasn't smart enough to keep choosing that plan, and I haven't been able to induce it to choose the better plan since. I tried freeing the proc cache, and i tried regenerating statistics. So I'm pretty sure a better plan is available, if i could coax the query optimizer to choose it. <br/><br/>Any thoughts? At this point, it looks like I'll have to use the index hint -- unless someone has other ideas? The only thing I haven't tried yet that I am aware of is changing from the &quot;empty set&quot; concept to using NULL values, also described in Bob's blog. <br/><br/>Thanks for any ideas.<br/>Kevin<br/><br/><hr class="sig">KevinThu, 01 Oct 2009 20:20:32 Z2009-10-13T02:44:32Zhttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/0dcc7dd7-4994-4e78-b87b-63ed66a9362ehttp://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/0dcc7dd7-4994-4e78-b87b-63ed66a9362eAnonymous_189http://social.msdn.microsoft.com/Profile/en-US/?user=Anonymous_189Conversions numeric for spatial dataHi All,<br/> <br/> The code that I am reviewing test whether a certain point belongs in a specific polygon. It should also return polygons that is within a certain range of the point. <br/> <br/> I am passing in feet value. In the code it translate the feet into metre ( I am assuming. That is the unit said in the sys.spatial_reference_systems for SRID 4326). <br/> <br/> What confuses me is the feet value that is pass in is multiply by 0.00000272.   So 750 feet is convert to 750 X 0.00000272.  Does anyone know where this numeric transformation is derived from? <br/> <br/> I have polygons loaded under SRID 4326 and I need to test a certain point. All polygons that is 750 feet from this point needs to be return.  Any help is much appreciated.<br/> <br/> thanks,<br/>Wed, 30 Sep 2009 15:53:08 Z2009-10-08T13:03:49Z