Share via


Transforming Latitude and Longitude into Geography SQL Server Type

SQL Server 2008 provides support for spatial data and many accompanying functions. SQL Server Reporting Services 2008 R2 has a built in support for maps (SHD files or even bing maps). There is a handy wizard in Report Builder 3.0 that will guide you through through the report creation process with map. If you want to use Bing Maps you have to have a Geography type in your SQL datasource somewhere.

I recently faced a situation where the customer had the Lat & Long coordinates of the spots which should be plotted in a map. In order to convert lat & long in Geography type use the following T-SQL:

geography::STPointFromText('POINT(' + CAST([Longitude] AS VARCHAR(10)) + ' ' +
CAST([Latitude] AS VARCHAR(10)) + ')', 4326)

Then you have the option of using the Bing maps in your SSRS reports.

Comments

  • Anonymous
    June 29, 2011
    geography sql information is many companies used....use bing maps, geography datasource................. Thank you................. saritha. <a href=“http://www.nandisofttech.com”>geography</a>

  • Anonymous
    June 29, 2011
    If you want to use Bing Maps you have to have a Geography type in your SQL datasource somewhere.


sandhya

  • Anonymous
    May 01, 2013
    How do I do this in reverse. I have a geography column that I need to get lat and long information from.

  • Anonymous
    February 18, 2014
    [Column].EnvelopeCenter().Lat or Long - EnvelopeCenter is an estimate.