geometry STAsText returns spatial text without the Z and M values carried by an instance. I compare it with ToString using two points. Identical XY text can hide a difference in the original payload.
geometry STDistance: Measure the Closest Points of Two Shapes
geometry STDistance measures the shortest distance between points belonging to two represented shapes. I compare an interior gap with an endpoint gap. Intersecting shapes provide a useful zero-distance case.
geometry STGeometryType: Type Names Say More Than Dimension
geometry STGeometryType identifies the represented shape type, which carries more information than its dimension. I compare single and multiple shapes in one small query. Equal dimensions do not mean that their structures are interchangeable.
geometry Collections: Read Members With STGeometryN
geometry Collections hold member shapes that STGeometryN can return individually. I extract a point and a line from one fixed collection. A third request deliberately exceeds its member count.
geometry STIsEmpty: Empty Shapes Are Different From SQL NULL
geometry STIsEmpty tests whether an existing spatial instance has an empty point set. I keep that condition separate from SQL NULL. A missing database value and a present empty geometry are different inputs.
Finding the Nearest Location With a Spatial Index
A nearest location query in SQL Server needs TOP, STDistance in WHERE and ORDER BY, matching SRIDs, and a checked spatial plan.
Spatial Indexes: Speeding Up Distance Searches
Use spatial indexes for geography distance searches, compare actual plans and reads, and inspect tessellation with built-in diagnostics.







