Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The distance returned depends on the <a href="http://technet.microsoft.com/en-us/library/bb964707.aspx" rel="nofollow noreferrer">"Spatial Reference Identifier (SRID)"</a> you define for your geography types.</p> <p>In the example below, the default <a href="http://technet.microsoft.com/en-us/library/bb964707.aspx" rel="nofollow noreferrer">SRID</a> of 4336 is used, see the second argument of <a href="http://msdn.microsoft.com/en-us/library/bb933823.aspx" rel="nofollow noreferrer">STGeomFromText</a>. This means the distance returned is in meters, you find this via querying the catalog view <a href="http://technet.microsoft.com/en-us/library/bb964707.aspx" rel="nofollow noreferrer">spatial_reference_systems</a> i.e. <code>select srs.unit_of_measure from sys.spatial_reference_systems as srs where srs.spatial_reference_id = 4326</code></p> <p>As an alternative to <a href="http://msdn.microsoft.com/en-us/library/bb933823.aspx" rel="nofollow noreferrer">STGeomFromText</a>, you can use <a href="http://msdn.microsoft.com/en-us/library/bb933824.aspx" rel="nofollow noreferrer">parse</a> which assumes a <a href="http://technet.microsoft.com/en-us/library/bb964707.aspx" rel="nofollow noreferrer">SRID</a> of 4326 and you don't have to specify one explicitly.</p> <p>When calculating the distance between two points, you must use the same <a href="http://technet.microsoft.com/en-us/library/bb964707.aspx" rel="nofollow noreferrer">SRID</a> for both geography types else you get an error. Example:</p> <pre><code>DECLARE @address1 GEOGRAPHY DECLARE @address2 GEOGRAPHY DECLARE @distance float SET @address1 = GEOGRAPHY::STGeomFromText ('point(53.046908 -2.991673)',4326) SET @address2 = GEOGRAPHY::STGeomFromText ('point(51.500152 -0.126236)',4326) SET @distance = @address1.STDistance(@address2) SELECT @distance --this is the distance in meters </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload