Converts the geometry to a multilinestring value.
SELECT Shape.ST_Length() FROM SpatialShapes WHERE ShapeID = 29
The following uses ST_ToMultiLine to change the type of the Shape column expression to ST_MultiLineString. This example would also work with ShapeID 5, where the Shape value is of type ST_LineString. ST_Length returns the result 4.236068.
SELECT Shape.ST_ToMultiLine().ST_Length() FROM SpatialShapes WHERE ShapeID = 29
In this case, the value of the Shape column is known be of type ST_MultiLineString, so TREAT can be used to efficiently change the type of the expression. This example would notwork with ShapeID 5, where the Shape value is of type ST_LineString. ST_Length returns the result 4.236068.
SELECT TREAT( Shape AS ST_MultiLineString ).ST_Length() FROM SpatialShapes WHERE ShapeID = 29
SQL/MM (ISO/IEC 13249-3: 2006) 5.1.33