title: A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":
body: <p>I am trying to run below query in sql server 2008 .</p>
  
  <p><code>select geography::STGeomFromText(Shape.STAsText(),4326).STArea() from PARCELS_AZ</code></p>
  
  <p>I am getting the execption - </p>
  
  <blockquote>
    <p>A .NET Framework error occurred during execution of user-defined
    routine or aggregate "geography":  System.ArgumentException: 24200:
    The specified input does not represent a valid geography instance.
    System.ArgumentException:     at
    Microsoft.SqlServer.Types.SqlGeography.ConstructGeographyFromUserInput(GeoData
    g, Int32 srid)    at
    Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType
    type, SqlChars taggedText, Int32 srid)</p>
  </blockquote>
  
  <p>I am trying to calculate area for polygons, but getting this exception.</p>
  
  <p>How can I change my query to calculate area so that area will be calculated only for valid geometries?</p>