To convert the latitude and longitude coordinates to a geography point, we will use the StPointFromText function.
The STPointFromText returns a geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
UPDATE Locations set [GeoLocation] = geography::STPointFromText('POINT(' + CAST([Lon] AS VARCHAR(20)) + ' ' + CAST([Lat] AS VARCHAR(20)) + ')', 4326)
The STPointFromText returns a geography instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) representation.
CREATE TABLE Locations(lat float ,lon float,[GeoLocation] GEOGRAPHY)
INSERT INTO Locations(lat,lon)values
((34.1433454039943,-118.408653442307),34.2228933701786,-119.152547489247)
((34.1433454039943,-118.408653442307),34.2228933701786,-119.152547489247)
No comments:
Post a Comment