Geography type SQL Server R2 - Query to populate a new Geography Field with known Lat/long data
i love idea special geo type make easier , faster find places in data table in radius of given lat/long..
so thinking should able write relativity simple query create , populate new column or new table geo information (if new table linking id)
something of course not working @ all...
create table geolocatons
select places.id, geography::stpointfromtext(lat & long) geodata
places
i have no idea @ point syntax of geography::stpointfromtext(lat & long) part is...
seems common need can't find straight forward example...
- 10spotdomain domain , domain related needs
ok here answer have found works, below link whole thing...
http://www.sql-server-helper.com/sql-server-2008/convert-latitude-longitude-to-geography-point.aspx
here part needed:
the problem format 'argument' geography ::stpointfromtext function odd - must string contains text ==> point... etc see in example below. works!
using geography::stpointfromtext
the first thing add new column store geography point. can done alter table statement , use geography data type new column.
alter table [dbo].[landmark] add [geolocation] geography go
to convert latitude , longitude coordinates geography point, use stpointfromtext function. stpointfromtext returns geography instance open geospatial consortium (ogc) well-known text (wkt) representation.
update [dbo].[landmark] set [geolocation] = geography::stpointfromtext('point(' + cast([longitude] varchar(20)) + ' ' + cast([latitude] varchar(20)) + ')', 4326) go
- 10spotdomain domain , domain related needs
SQL Server > SQL Server Spatial
Comments
Post a Comment