Sunday, November 23, 2008

SQL Server 2008 – Spatial Data in 3D

Last week I attended an MSDN event in downtown Denver where one of the technologies demonstrated was SQL Server 2008. SQL Server 2008 supports spatial data and all the demos showed only data in 2 dimensions (X,Y).

I was wondering if SQL Server 2008 supported 3 dimensional data (X,Y,Z) and came across this post/tutorial and it does!


The .AsTextZM()  and .ToString() can be used on a spatial datatype to get the X,Y,Z (and M) values of a geometry.

On the other hand, .STAsText() returns only the X,Y values of a geometry.


And to create geometries you use a function like: STMPolyFromText

geometry::STMPolyFromText('MULTIPOLYGON (((5 5, 10 5, 10 10, 5 5)), ((10 10, 100 10, 200 200, 30 30, 10 10)))', 0);


To find out how to construct various geomteries in WKT, see

No comments: