SQL Server Spatial: Write a query to update a geography column from decimal latitude and longitude fields

Platform:SQL Server Spatial
Task:Write a query to update a geography column from decimal latitude and longitude fields
Discussion:
I had a table with latitude and longitude coordinates stored in two decimal columns but I wanted to convert those decimal coordinates into a geography data type in a third column. Here is how I did it
Example:
UPDATE CaribouLocations SET Coordinates = (Geography::STPointFromText('POINT (' + CAST(Lon AS VARCHAR(50)) + ' ' + CAST(Lat AS VARCHAR(50)) + ')',4326))
Back to Index