Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert latitude and longitude to geometry attribu

Author  Topic 

mavericky
Posting Yak Master

117 Posts

Posted - 2011-07-01 : 16:53:53
Hi all,
Is there any way I can convert latitude and longitude values into geometery datatype and store in sql database?

Thanks,
Mavericky

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-01 : 22:32:48
Yes.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-07-01 : 22:38:09
Here is the basics
DECLARE	@longitude DECIMAL(9, 6),
@latitude DECIMAL(9, 6),
@location GEOGRAPHY

SET @Location = geography::STGeomFromText('POINT (' + STR(@longitude, 20, 10) + ' ' + STR(@latitude, 20, 10) + ')', 4326)



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -