title: Create geography polygon from points in T-SQL
body: <p>In my SQL Server (2008 R2) on Azure, there's a table containing a lot of geographical <code>Points</code> (latitude/longitude):</p>
  
  <pre><code>CREATE TABLE MyPoints
  (
    Region uniqueidentifier NOT NULL,
    Number int NOT NULL,
    Position geography NOT NULL,
    CONSTRAINT PK_MyPoints PRIMARY KEY(Region, Number)
  )
  </code></pre>
  
  <p>Now I want to create a <code>Polygon</code> from this points to determine, which of my stores are located in the area defined by the points.</p>
  
  <p>Is there a native and fast way to build a polygon from the given points in T-SQL? <a href="http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/0ff0e3ec-fcb3-4aaa-9fbc-dbca6186d717" rel="noreferrer">The solutions I found</a> are using the <code>STGeomFromText</code>/<code>STGeomFomWKB</code> methods to create a polygon, which seems very cumbersome and slow to me.</p>
  
  <p>Something like:</p>
  
  <pre><code>SET @POLY = geometry::STPolyFromPoints(SELECT Position FROM MyPoints)
  </code></pre>