<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>SQL</title>
        <link>http://www.jasonfollas.com/blog/category/6.aspx</link>
        <description>SQL</description>
        <language>en-US</language>
        <copyright>Jason Follas</copyright>
        <managingEditor>jason@jasonfollas.com</managingEditor>
        <generator>Subtext Version 2.0.0.43</generator>
        <item>
            <title>Speaking at Microsoft SQL Server User Group in Columbus, June 5</title>
            <link>http://jasonfollas.com/blog/archive/2009/05/20/speaking-at-microsoft-sql-server-user-group-in-columbus-june.aspx</link>
            <description>&lt;p&gt;&lt;font face="Arial"&gt;On June 5th, I'll be in Columbus (Ohio) speaking to the &lt;a target="_blank" href="https://www.resultdata.com/training/schedule/register.aspx?id=198020"&gt;Microsoft SQL Server User Group&lt;/a&gt; (Result Data) about using the XML data type in SQL Server.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;strong&gt;XML Capabilities of SQL Server 2008&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;Jason Follas, Microsoft MVP for SQL Server, will lead a discussion on the XML capabilities of SQL Server 2008.  XML-based data is very prevalent in today's data world to the point that every database developer should know how to work with XML. Middle-tier translation of XML into relational data may be inflexible, and often leads to a loss of fidelity over time. One solution is to move the XML handling into the database itself in order to improve overall integration. SQL Server 2008 provides powerful XML processing features that allow easy access to data stored within XML without sacrificing any of the original fidelity.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;strong&gt;Partitioning in SQL Server 2008&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;Andy Thissen, Database Administrator at BMW Financial Services, will lead a discussion of the use of partitioning in SQL Server 2008. &lt;br /&gt;
 &lt;br /&gt;
Agenda&lt;br /&gt;
 &lt;br /&gt;
12:45    Check-In&lt;br /&gt;
1:15       Introduction &amp;amp; Announcements&lt;br /&gt;
1:30       XML Capabilities of SQL Server 2008&lt;br /&gt;
2:30       BREAK&lt;br /&gt;
2:45       Partitioning in SQL Server 2008&lt;br /&gt;
3:30       Q&amp;amp;A&lt;br /&gt;
3:45       Raffle – Door Prize &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;a href="https://www.resultdata.com/training/schedule/register.aspx?id=198020"&gt;https://www.resultdata.com/training/schedule/register.aspx?id=198020&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://jasonfollas.com/blog/aggbug/69.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2009/05/20/speaking-at-microsoft-sql-server-user-group-in-columbus-june.aspx</guid>
            <pubDate>Wed, 20 May 2009 15:00:05 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2009/05/20/speaking-at-microsoft-sql-server-user-group-in-columbus-june.aspx#feedback</comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/69.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/69.aspx</trackback:ping>
        </item>
        <item>
            <title>For Jeff: Spatial Querying</title>
            <link>http://jasonfollas.com/blog/archive/2009/03/04/for-jeff-spatial-querying.aspx</link>
            <description>&lt;p&gt;A quick sample of usage as requested by my friend &lt;a href="http://www.mcwherter.net/blog/"&gt;Jeff McWherter&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;Querying for all data in a table where the "zip code polygon" is within 20 miles of a geocode point (must convert 20 miles to meters in the predicate)::&lt;/p&gt;
&lt;pre class="sql" name="code"&gt;select * 
from dbo.fe_2007_us_zcta500 
where Boundary.STDistance('POINT(-79.8884595930576 43.2609696686268)') &amp;lt; (20 * 1609.344) &lt;/pre&gt;
&lt;img src="http://jasonfollas.com/blog/aggbug/67.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2009/03/04/for-jeff-spatial-querying.aspx</guid>
            <pubDate>Wed, 04 Mar 2009 23:08:55 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2009/03/04/for-jeff-spatial-querying.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/67.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/67.aspx</trackback:ping>
        </item>
        <item>
            <title>How To Force SSRS To Use Latest Data</title>
            <link>http://jasonfollas.com/blog/archive/2009/02/25/how-to-force-ssrs-to-use-latest-data.aspx</link>
            <description>&lt;p&gt;SQL Server Reporting Services is great in the fact that it comes with a handful of different rendering (export) formats out of the box.  If a particular report is intended to be paginated and printed, then from my web applications, I will often link to the report with a parameter instructing the render format to be PDF - this way, the user is never taken to the report viewer (they just get an Open/Save As dialog for the PDF itself).&lt;/p&gt;
&lt;p&gt;The URL for such a link may resemble the following:&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;http://server/ReportServer?/path/reportname&amp;amp;rs:Command=Render&amp;amp;rc:LinkTarget=_blank&amp;amp;&lt;strong&gt;&lt;u&gt;rs:Format=PDF&lt;/u&gt;&lt;/strong&gt;&amp;amp;SomeParameterValue=1&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;There are other interesting things that you can do with the rs:Format parameter.  For instance, say that you create a tiny report that only contains a chart.  Why not have this report rendered as an image, and then you can show this chart on your website (i.e., no extra charting component would be necessary on your web server).  Simply specify the URL to your report in an IMG tag's SRC property, and include the following parameters in that URL:&lt;/p&gt;
&lt;p&gt;rs:Format=IMAGE&amp;amp;rc:OutputFormat=PNG   (or GIF, or JPG, etc)&lt;/p&gt;
&lt;p&gt;One problem with not going through the default web-based report viewer, though: the report server likes to cache the output for your browser session.  Therefore, if the underlying data changes, re-running these reports will not show the updated information unless you close your browser and hit the page again.&lt;/p&gt;
&lt;p&gt;After a bit of headscratching and searching on the Internet, I found an easy solution that can be used to always force the reports to query the database.  Simply include the following parameter in your report's URL:&lt;/p&gt;
&lt;p&gt;rs:ClearSession=true&lt;/p&gt;
&lt;p&gt;Of course, you will take more of a hit on your database (because the report will always requery its datasets).  But, perhaps in your solution, you can selectively use this parameter if the user wants to force a refresh of a report that is automatically rendered to PDF or an image - that's a design decision that you'll have to make.  &lt;/p&gt;
&lt;p&gt;I'm just happy that a mechanism exists to get around the default behavior!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;font face="Arial" /&gt;&lt;/p&gt;&lt;img src="http://jasonfollas.com/blog/aggbug/66.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2009/02/25/how-to-force-ssrs-to-use-latest-data.aspx</guid>
            <pubDate>Wed, 25 Feb 2009 19:02:27 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2009/02/25/how-to-force-ssrs-to-use-latest-data.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/66.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/66.aspx</trackback:ping>
        </item>
        <item>
            <title>Knowledge++ [4]</title>
            <link>http://jasonfollas.com/blog/archive/2009/02/21/knowledge-4.aspx</link>
            <description>&lt;p&gt;I recently developed a spatially-aware .NET application that did not use SQL Server 2008 as the backend (this enterprise was still on SS2005, but we needed the spatial support in the application today).  While the application worked properly on my laptop, it was a huge failboat when deployed to the server environment.&lt;/p&gt;
&lt;p&gt;I had previously posted that you can get the Microsoft.SqlServer.Types library from MS Downloads, but it turns out that this alone is not sufficient to allow your application to run.  You also need to ensure that the SQL Server 2008 Native Client is also installed (regardless of whether you're accessing a SS2008 instance or not). &lt;em&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;Update!&lt;/font&gt; &lt;/strong&gt;You actually don't... read below.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Both the Types library and the Native Client can be downloaded from the following:&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=228de03f-3b5a-428a-923f-58a033d316e1&amp;amp;DisplayLang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=228de03f-3b5a-428a-923f-58a033d316e1&amp;amp;DisplayLang=en&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;My discovery source: &lt;font face="Arial"&gt;&lt;a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=355402&amp;amp;wa=wsignin1.0"&gt;https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=355402&amp;amp;wa=wsignin1.0&lt;/a&gt;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE: &lt;/strong&gt;Per &lt;a href="http://blogs.msdn.com/isaac/default.aspx"&gt;Isaac Kunen&lt;/a&gt; (in this blog post's comments as well as offline discussion), the missing component from the Types library is simply an updated version of the C Runtime.  The fix of using the Native Client is a hack in this case because its MSI actually installs the updated CRT (which the MSI for the Types library should have done also - it's a goof that MS Downloads hasn't been updated with an updated version of the Types API after the above Connect feedback was answered...&lt;/p&gt;
&lt;p&gt;The Microsoft Visual C++ 2008 redistributable by itself can be downloaded from:&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&amp;amp;displaylang=en&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://jasonfollas.com/blog/aggbug/63.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2009/02/21/knowledge-4.aspx</guid>
            <pubDate>Sun, 22 Feb 2009 02:45:26 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2009/02/21/knowledge-4.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/63.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/63.aspx</trackback:ping>
        </item>
        <item>
            <title>Knowledge++ [3]</title>
            <link>http://jasonfollas.com/blog/archive/2009/01/29/knowledge-3.aspx</link>
            <description>&lt;p&gt;When you write a query that SELECTs a SQL Server 2008 Spatial type, the returned result is a binary value.  Without closely examining the bytes, I just assumed that this was WKB (Well-Known Binary).&lt;/p&gt;
&lt;p&gt;Well, as it turns out, the bytes that are returned are simply a serialized version of the .NET object (the UDT has a Write() method that it calls internally to serialize the object in binary).  This is NOT directly compatible with WKB.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;My discovery source: &lt;font face="Arial"&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/40ee9466-d7bf-4340-b295-53217ae5128e"&gt;http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/40ee9466-d7bf-4340-b295-53217ae5128e&lt;/a&gt;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;
&lt;img src="http://jasonfollas.com/blog/aggbug/62.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2009/01/29/knowledge-3.aspx</guid>
            <pubDate>Thu, 29 Jan 2009 14:32:28 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2009/01/29/knowledge-3.aspx#feedback</comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/62.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/62.aspx</trackback:ping>
        </item>
        <item>
            <title>Using SQL Server Spatial Objects as ADO.NET Parameter Values</title>
            <link>http://jasonfollas.com/blog/archive/2008/12/11/using-ado.net-with-sql-server-spatial-objects.aspx</link>
            <description>&lt;p&gt;I've &lt;a target="_blank" href="http://jasonfollas.com/blog/archive/2008/06/23/sql-server-2008-spatial-data-part-8.aspx"&gt;previously mentioned&lt;/a&gt; that the SQL Server 2008 Spatial data types are freely available for use in your .NET applications, regardless of whether you have SQL Server 2008 or not.  This allows you to incorporate some powerful spatial capabilities right into your application.  &lt;/p&gt;
&lt;p&gt;&lt;em&gt;(Look for "&lt;font face="Arial"&gt;Microsoft SQL Server System CLR Types" on this page: &lt;font face="Arial"&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=228DE03F-3B5A-428A-923F-58A033D316E1&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=228DE03F-3B5A-428A-923F-58A033D316E1&amp;amp;displaylang=en&lt;/a&gt; )&lt;/font&gt;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;However, in most usage scenarios, there will come a time when you have an instance of a SQL Server spatial object in your .NET application, and need to commit it to your SQL Server 2008 database.  How would you do this, without losing fidelity or resorting to serialization of the object to WKT first?&lt;/p&gt;
&lt;p&gt;The solutions is to create a Parameter object of type System.Data.SqlDbType.Udt.  Then set the UdtTypeName parameter to the SQL Server-recognized type name (i.e., for SqlGeometry, you would simply use Geometry).&lt;/p&gt;
&lt;p&gt;The following code demonstrates executing an UPDATE statement that sets the value of a Spatial field to a newly constructed object.&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;using (SqlConnection conn = new SqlConnection("Server=.;Integrated Security=true;Initial Catalog=scratch"))
{
   using (SqlCommand cmd = new SqlCommand("UPDATE fe_2007_us_zcta500 SET Boundary=@boundary WHERE id=@id", conn))
   {
      SqlParameter id = cmd.Parameters.Add("@id", System.Data.SqlDbType.Int);

      SqlParameter boundary = cmd.Parameters.Add("@boundary", System.Data.SqlDbType.Udt);
      boundary.UdtTypeName = "geometry";

      SqlGeometry geom = SqlGeometry.Parse("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))");
      
      boundary.Value = geom;
      id.Value = 123;

      conn.Open();
      cmd.ExecuteNonQuery();
      conn.Close();
   }
}
&lt;/pre&gt;&lt;img src="http://jasonfollas.com/blog/aggbug/58.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2008/12/11/using-ado.net-with-sql-server-spatial-objects.aspx</guid>
            <pubDate>Thu, 11 Dec 2008 19:04:12 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2008/12/11/using-ado.net-with-sql-server-spatial-objects.aspx#feedback</comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/58.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/58.aspx</trackback:ping>
        </item>
        <item>
            <title>Flashy SQL Server 2008 Site</title>
            <link>http://jasonfollas.com/blog/archive/2008/12/08/flashy-sql-server-2008-site.aspx</link>
            <description>&lt;p&gt;&lt;a target="_blank" href="http://www.microsoft.com/servers/sql/2008/sqlserverenergy/en/us/default.aspx"&gt;&lt;img alt="SQL Server 2008: It's a new form of energy." hspace="5" align="right" border="0" src="http://jasonfollas.com/blog/images/jasonfollas_com/blog/9/o_SQL2008Energy.png" /&gt;&lt;/a&gt;As a matter of principal, not to mention terms of service, I don't often click on ads that appear on &lt;a href="http://jasonfollas.com/blog"&gt;my own blog&lt;/a&gt;.  But, when I see an ad on my site that interests me, I follow it (I believe Google knows who I am, so I don't get "credit" for that click).&lt;/p&gt;
&lt;p&gt;Such was the case the other day when I saw a flashy plasma-lamp-like animated advertisement in &lt;a href="http://jasonfollas.com/blog"&gt;my site&lt;/a&gt;'s sidebar with the words "They're not just new forms of data... It's a new form of energy.  SQL Server 2008".&lt;/p&gt;
&lt;p&gt;I won't ask you to click on the ad from &lt;a href="http://jasonfollas.com/blog"&gt;my site&lt;/a&gt;, but give the destination site a whirl to learn about the cool things that SQL Server 2008 can do (including something that I'm very interested in: spatial querying):&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;&lt;a target="_blank" href="http://www.microsoft.com/servers/sql/2008/sqlserverenergy/en/us/default.aspx"&gt;http://www.microsoft.com/servers/sql/2008/sqlserverenergy/en/us/default.aspx&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://jasonfollas.com/blog/aggbug/57.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2008/12/08/flashy-sql-server-2008-site.aspx</guid>
            <pubDate>Mon, 08 Dec 2008 20:14:40 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2008/12/08/flashy-sql-server-2008-site.aspx#feedback</comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/57.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/57.aspx</trackback:ping>
        </item>
        <item>
            <title>SqlGeography: Ring Orientation of Polygon Interior Rings (Holes)</title>
            <link>http://jasonfollas.com/blog/archive/2008/11/25/sqlgeography-ring-orientation-of-polygon-interior-rings-holes.aspx</link>
            <description>&lt;p&gt;I have mentioned before how the Ring Orientation for the exterior ring of a Polygon is significant when instantiating a SqlGeography object.  In this case, a Counter-Clockwise orientation is required so that as an observer walks along the path, the interior of the Polygon is always to their left.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Ring Orientation for SqlGeography" hspace="5" align="right" src="http://jasonfollas.com/blog/images/jasonfollas_com/blog/9/r_RingOrientation.PNG" /&gt;But, what I have never really seen documented (or paid attention to, at least) is the fact that the interior rings, or holes, of a Polygon also have specific Ring Orientation requirements.  &lt;/p&gt;
&lt;p&gt;In keeping with the "Left-handed" rule, interior rings must be defined in a Clockwise manner - the opposite orientation of the shape's exterior ring.  This is because holes within a Polygon are considered to be part of the exterior of the shape, so the observer walking in a Clockwise direction is still keeping the Polygon's interior to their left.&lt;/p&gt;
&lt;p&gt;(I should note here that the Ring Orientation for SqlGeography is the exact opposite of ESRI's ShapeFile format, which is why Ring Orientation has been on my mind for the past few days).&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://jasonfollas.com/blog/aggbug/55.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2008/11/25/sqlgeography-ring-orientation-of-polygon-interior-rings-holes.aspx</guid>
            <pubDate>Tue, 25 Nov 2008 14:14:18 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2008/11/25/sqlgeography-ring-orientation-of-polygon-interior-rings-holes.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/55.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/55.aspx</trackback:ping>
        </item>
        <item>
            <title>Spatial: Determining Ring Orientation</title>
            <link>http://jasonfollas.com/blog/archive/2008/11/24/spatial-determining-ring-orientation.aspx</link>
            <description>&lt;p&gt;A Ring is a list of points such that the starting point and ending point are the same (forming a closed shape).  The order the you define the points that make up a Ring  - known as Ring Orientation - is significant, for various data formats (including SQL Server's Geography type) imply special meaning for rings that are defined in a clockwise manner as opposed to a counter-clockwise manner.  &lt;/p&gt;
&lt;p&gt;Given a list of points with no additional context, it can be difficult to determine the Ring Orientation being used.  &lt;/p&gt;
&lt;p&gt;For example, suppose that you have a generic list of points that represent the boundary of a postal code, and that you wish to use these points in order to construct a Polygon instance using the SqlGeography type.  SqlGeography happens to use "Left-handed" ordering, so that as an observer walks along the set of points in the order defined, the "inside" of the polygon is always to their left.  This also implies that the exterior ring of a Polygon is defined in a counter-clockwise manner.&lt;/p&gt;
&lt;p&gt;If you try to define a polygon with an area greater than a single hemisphere (this is a nice way to say "if you screw up and use the wrong orientation"), then the SqlGeography type will throw an exception.  So, aside from using Try-Catch, what can you do?&lt;/p&gt;
&lt;p&gt;While researching solutions to this problem, I stumbled upon a paper entitled "&lt;a href="http://www.engr.colostate.edu/~dga/dga/papers/point_in_polygon.pdf"&gt;A Winding Number and Point-in-Polygon Algorithm&lt;/a&gt;" from the Colorado State University.  It turns out that a simple algorithm with O(n) complexity can be used to determine if a point is within a Polygon, and a side effect also provides the Ring Orientation.  The key to this algorithm is determining the trend of the ring at each crossing of an axis.&lt;/p&gt;
&lt;p&gt;Since I was only interested in Ring Orientation (and not point enclosure detection), I didn't need to use this particular algorithm.  Instead, I took inspiration from the winding concept, and created a simpler derivative algorithm:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Visual example of how to determine ring orientation at the extreme left point" hspace="5" align="right" src="http://jasonfollas.com/blog/images/jasonfollas_com/blog/9/o_orientation_example.png" /&gt; &lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Iterate the point collection and determine the extreme "left" and "right" points &lt;/li&gt;
    &lt;li&gt;Normalize the line segments connected to these points so that they each have the same "X" dimension length &lt;/li&gt;
    &lt;li&gt;Compare the "Y" values of the normalized segments to establish the trend through that extreme point (i.e., is the "previous" segment above or below the "next" segment) &lt;/li&gt;
    &lt;li&gt;In the spirit of the Winding algorithm, use opposite orientations for the left and right points so that the results coincide with one another &lt;/li&gt;
    &lt;li&gt;A negative result (negative indicates Clockwise orientation, positive result indicates Counter-Clockwise orientation, and a result of zero would be undefined &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I've actually written (and posted) several versions of this algorithm, each time discovering some edge case exception that would cause me to take down the post and rewrite the algorithm.  I believe the code below works for all simple polygons on a Cartesian coordinate system (read: I have more testing to see if this will work with an ellipsoidal model, like SqlGeography).  &lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note: The following code is generic in nature, and as such, I've defined my own Point structure instead of using a SqlGeometry or SqlGeography, etc. &lt;/em&gt;&lt;/p&gt;
&lt;pre class="c#" name="code"&gt;struct Point
{
    public double X { get; set; }
    public double Y { get; set; }
}

enum RingOrientation : int
{
    Unknown = 0,
    Clockwise = -1,
    CounterClockwise = 1
};

RingOrientation Orientation(Point[] points)
{
    // Inspired by http://www.engr.colostate.edu/~dga/dga/papers/point_in_polygon.pdf

    // This algorithm is to simply determine the Ring Orientation, so to do so, find the
    // extreme left and right points, and then check orientation

    if (points.Length &amp;lt; 4)
    {
        throw new ArgumentException("A polygon requires at least 4 points.");
    }

    if (points[0].X != points[points.Length - 1].X || points[0].Y != points[points.Length - 1].Y)
    {
        throw new ArgumentException("The array of points is not a polygon.  The first and last point must be identical.");
    }

    int rightmostIndex = 0;
    int leftmostIndex = 0;

    for (int i = 1; i &amp;lt; points.Length; i++)
    {
        if (points[i].X &amp;lt; points[leftmostIndex].X)
        {
            leftmostIndex = i;
        }
        if (points[i].X &amp;gt; points[rightmostIndex].X)
        {
            rightmostIndex = i;
        }
    }


    Point p0; // Point before the extreme
    Point p1; // The extreme point
    Point p2; // Point after the extreme

    double m; // Holds line slope

    double lenP2x;  // Length of the P1-P2 line segment's delta X
    double newP0y;  // The Y value of the P1-P0 line segment adjusted for X=lenP2x

    RingOrientation left_orientation;
    RingOrientation right_orientation;

    // Determine the orientation at the Left Point
    if (leftmostIndex == 0)
        p0 = points[points.Length - 2];
    else
        p0 = points[leftmostIndex - 1];

    p1 = points[leftmostIndex];

    if (leftmostIndex == points.Length - 1)
        p2 = points[1];
    else
        p2 = points[leftmostIndex + 1];

    m = (p1.Y - p0.Y) / (p1.X - p0.X);

    if (double.IsInfinity(m))
    {
        // This is a vertical line segment, so just calculate the dY to
        // determine orientation

        left_orientation = (RingOrientation)Math.Sign(p0.Y - p1.Y);
    }
    else
    {
        lenP2x = p2.X - p1.X;
        newP0y = p1.Y + (m * lenP2x);

        left_orientation = (RingOrientation)Math.Sign(newP0y - p2.Y);
    }



    // Determine the orientation at the Right Point
    if (rightmostIndex == 0)
        p0 = points[points.Length - 2];
    else
        p0 = points[rightmostIndex - 1];

    p1 = points[rightmostIndex];

    if (rightmostIndex == points.Length - 1)
        p2 = points[1];
    else
        p2 = points[rightmostIndex + 1];

    m = (p1.Y - p0.Y) / (p1.X - p0.X);

    if (double.IsInfinity(m))
    {
        // This is a vertical line segment, so just calculate the dY to
        // determine orientation

        right_orientation = (RingOrientation)Math.Sign(p1.Y - p0.Y);
    }
    else
    {
        lenP2x = p2.X - p1.X;
        newP0y = p1.Y + (m * lenP2x);

        right_orientation = (RingOrientation)Math.Sign(p2.Y - newP0y);
    }


    if (left_orientation == RingOrientation.Unknown)
    {
        return right_orientation;
    }
    else
    {
        return left_orientation;
    }
}


void Test()
{
    // Simple triangle - left extreme point is vertically "in between" line segments
    Point[] points = new Point[]
    {
        new Point(5,-1),
        new Point(0,0),
        new Point(5,1),
        new Point(5,-1)
    };

    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.Clockwise);
    Array.Reverse(points);
    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.CounterClockwise);

    // Case where both line segments are above the left extreme point
    points = new Point[]
    {
        new Point(2,1),
        new Point(0,0),
        new Point(1,1),
        new Point(2,1)
    };

    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.Clockwise);
    Array.Reverse(points);
    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.CounterClockwise);

    // Case where both line segments are below the left extreme point
    points = new Point[]
    {
        new Point(2,-1),
        new Point(0,0),
        new Point(1,-1),
        new Point(2,-1)
    };

    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.CounterClockwise);
    Array.Reverse(points);
    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.Clockwise);

    // Case where line segment is vertical (slope cannot be determined)
    points = new Point[]
    {
        new Point(0,0),
        new Point(0,1),
        new Point(1,1),
        new Point(1,0),
        new Point(0,0)
    };

    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.Clockwise);
    Array.Reverse(points);
    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.CounterClockwise);

    // Case where angle thru left extreme point is a right angle
    points = new Point[]
    {
        new Point(0,0),
        new Point(1,1),
        new Point(1,-1),
        new Point(0,0)
    };

    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.Clockwise);
    Array.Reverse(points);
    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.CounterClockwise);

    // Real-world case from a SHP file
    points = new Point[]
    {
        new Point(-156.92467299999998,20.738695999999997),
        new Point(-156.924636,20.738822),
        new Point(-156.924608,20.73894),
        new Point(-156.92458,20.739082),
        new Point(-156.92460599999998,20.739234),
        new Point(-156.924551,20.739326),
        new Point(-156.924507,20.739241999999997),
        new Point(-156.924482,20.739082),
        new Point(-156.924466,20.738854999999997),
        new Point(-156.924387,20.738602999999998),
        new Point(-156.924308,20.738325),
        new Point(-156.924239,20.738063999999998),
        new Point(-156.92424,20.737887999999998),
        new Point(-156.924285,20.737811999999998),
        new Point(-156.924475,20.73762),
        new Point(-156.92458299999998,20.737603999999997),
        new Point(-156.924754,20.737579),
        new Point(-156.924851,20.737731),
        new Point(-156.924956,20.738101),
        new Point(-156.924909,20.738343999999998),
        new Point(-156.924818,20.738487),
        new Point(-156.92467299999998,20.738695999999997)
    };

    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.Clockwise);
    Array.Reverse(points);
    System.Diagnostics.Debug.Assert(Orientation(points) == RingOrientation.CounterClockwise);

}&lt;/pre&gt;&lt;img src="http://jasonfollas.com/blog/aggbug/54.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2008/11/24/spatial-determining-ring-orientation.aspx</guid>
            <pubDate>Mon, 24 Nov 2008 18:00:46 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2008/11/24/spatial-determining-ring-orientation.aspx#feedback</comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/54.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/54.aspx</trackback:ping>
        </item>
        <item>
            <title>SQL Server 2008 RTM Available for Download</title>
            <link>http://jasonfollas.com/blog/archive/2008/08/06/sql-server-2008-rtm-available-for-download.aspx</link>
            <description>&lt;p&gt;I found out about 15 minutes ago that SQL Server 2008 RTM version is available for download from MSDN!  Congratulations to the SQL Server team!&lt;/p&gt;
&lt;p&gt;As I watch the 3 GB download trickle slowly onto my hard drive, I'm left with a few questions at this point, like what version of NETFX will be installed when I run setup?  RC0 so nicely installed the .NET 3.5 SP1 Beta Framework onto my machine, and since .NET 3.5 SP1 itself has not RTM'd, what are they going to do?  Distribute the beta with the SQL Server RTM bits?  Release .NET 3.5 SP1 to manufacturing?  Remove the install dependency on .NET 3.5 SP1?  &lt;/p&gt;
&lt;p&gt;I'll know in [checking the download rate] about 3 days from now.  ;-)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; Well, come to find out, a few days later, Microsoft released the RTM version of NETFX 3.5 SP1.  You need to have Visual Studio 2008 fully upgraded to SP1 (which will include the NETFX 3.5 SP1) before installing SQL 2008.&lt;/p&gt;&lt;img src="http://jasonfollas.com/blog/aggbug/48.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Jason Follas</dc:creator>
            <guid>http://jasonfollas.com/blog/archive/2008/08/06/sql-server-2008-rtm-available-for-download.aspx</guid>
            <pubDate>Wed, 06 Aug 2008 19:46:30 GMT</pubDate>
            <comments>http://jasonfollas.com/blog/archive/2008/08/06/sql-server-2008-rtm-available-for-download.aspx#feedback</comments>
            <wfw:commentRss>http://jasonfollas.com/blog/comments/commentRss/48.aspx</wfw:commentRss>
            <trackback:ping>http://jasonfollas.com/blog/services/trackbacks/48.aspx</trackback:ping>
        </item>
    </channel>
</rss>