[GIS] Change the geometry type from LineString to MultiLineString SQL Server

geometrylinestringsqlsql server

I have a SQL Server database table to contains two geometry types: LineString; and, MultiLineString.

What is the best way to change the type of all of the LineString geometries to 1 part MultiLineString geometries?

I have tried:

UPDATE Footpaths
SET Geom.STGeometryType() = 'MultiLineString';

Best Answer

One solution I found was to set the geometry from text after reading the geometry as a text string and reformatting it:

UPDATE [GIS].[dbo].[Footpaths] SET [Geom] = geometry::STGeomFromText(CONCAT(REPLACE([Geom].STAsText(),'LINESTRING ', 'MULTILINESTRING ('),')'),28356) WHERE [Geom].STGeometryType() = 'LineString'