ordinates (longitude/latitude, from Google Maps) in SQL Server?

I'm designing a table in SQL Server 2008 that will store a list of users and a Google Maps co-ordinate (longitude & latitude).

Will I need two fields, or can it be done with 1?

What's the best (or most common) data-type to use for storing this kind of data?


Take a look at the new Spatial data-types that were introduced in SQL Server 2008. They are designed for this kind of task and make indexing and querying much easier and more efficient.

More information:

  • MS TechNet: SQL Server 2008 Spatial Data Types,

  • MSDN: Working with Spatial Data (Database Engine).


  • Fair Warning! Before taking the advice to use the GEOGRAPHY type, make sure you are not planning on using Linq or Entity Framework to access the data because it's not supported (as of November 2010) and you will be sad!

    Update Jul 2017

    For those reading this answer now, it is obsolete as it refers to backdated technology stack. See comments for more details.


    I don't know the answer for SQL Server but...

    In MySQL save it as FLOAT( 10, 6 )

    This is the official recommendation from the Google developer documentation.

    CREATE TABLE `coords` (
      `lat` FLOAT( 10, 6 ) NOT NULL ,
      `lng` FLOAT( 10, 6 ) NOT NULL ,
    ) ENGINE = MYISAM ;
    
    链接地址: http://www.djcxy.com/p/93904.html

    上一篇: 数据库/ SQL:如何存储经度/纬度数据?

    下一篇: SQL Server中的坐标(来自Google地图的经度/纬度)?