Skip to content
Advertisement

Add geometry column from exisiting x,y,z columns

I have a table as such:

enter image description here

All columns are Decimal(18, 3), there are also millions of rows.

I would like to add a fourth column to be a geometry point. I have tried but to no avail:

 alter table [dbo].[o5bim] add ogr_geometry as geometry::STGeomFromText('Point('+column1+' '+column2+' '+column3+')', 0)

Driving me insane! Cheers

Advertisement

Answer

As mentioned by @lptr in the comments, you can use STPointFromText

alter table dbo.[o5bim]
  add ogr_geometry as
    geometry::STPointFromText(concat('POINT (', column1, ' ', column2, ' ', column3, ')'), 0);  

db<>fiddle

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement