Is it different to update geography column in sql server than a regular field( varchar....). Can you please provide a sample statement to do this. thanks.
I am not sure if this is the answer you are looking for - but as I would say, the main difference is that when updating a "regular field", you typically provide directly the new value - for example:
UPDATE mytable SET name = 'John' WHERE id = 1
When updating a geography column, you probably cannot provide the value directly (since it is a very long hexadecimal number, which encodes the geoghraphy information) but you will want to compute it from some other values (which can, but do not have to be columns of the same table), e.g.:
UPDATE mytable SET gps=geography::STPointFromText('POINT(' + lng + ' ' + lat + ')', 4326)
where lng
and lat
are varchar values specifying the GPS coordinates in a "human-readable" format (like lat = '48.955790'
, lng = '20.524500'
) - in this case they are also columns of mytable
.