Skip to main content

SQL Server spatial support

View Markdown versionEdit this page on GitHub

Platform and version scope​

DBMS behavior: sources are Microsoft Learn's SQL Server 17.x (sql-server-ver17) documentation view, checked on 2026-10-11. A documentation view identifies the consulted source; it is not a tested compatibility range. The vendor explicitly distinguishes restrictions at compatibility level 100 and below. LongitudeOne evidence is pinned to Doctrine Spatial 6.0.0.

Spatial behavior​

SubjectSQL Server behavior and vendor source
Typesgeometry is planar; geography is ellipsoidal. They are column types; Point and other instances are not separate column types. Spatial overview
GeometriesPoint, LineString, Polygon, their three multi-types and GeometryCollection; CircularString, CompoundCurve and CurvePolygon; geography also has FullGlobe. Spatial overview
DimensionsPoint can store XY, XYZ, XYM and XYZM information through optional Z/M values; those values can also be NULL. Storage does not imply 3D computations. Point
CRS/SRIDInstances carry SRIDs; a column can contain different SRIDs. Binary spatial operations on different SRIDs return NULL. SRID reference
FormatsSTAsText() returns WKT without Z/M. STAsBinary() returns WKB. Internal spatial serialization is a distinct representation. STAsText, STAsBinary, JDBC spatial APIs
RestrictionsGeography polygon orientation determines the interior. Compatibility level 100 and below has hemisphere restrictions; circular arc calculations ignore Z. Spatial overview

Informative SQL example: this explicitly supplies the reference identifier and uses a planar geometry. It is not a LongitudeOne API example.

DECLARE @shape geometry = geometry::STGeomFromText('POINT(1 2)', 0);
SELECT @shape.STAsText(), @shape.STSrid;

Differences from standards​

Vendor representation: Microsoft's Point examples accept additional ordinates without OGC's Z, M or ZM WKT qualifiers, including NULL placeholders. Compare the OGC 06-103r4 dimensional grammars (7.2.3–7.2.5) through the representation reference; SQL Server syntax is not evidence that those grammars accept the same text.

Vendor extension and model: FullGlobe and geography's ellipsoidal interior rules are SQL Server behavior. Curved types are not all proprietary merely because they are absent from a particular OGC grammar; consult the separate SQL/MM reference. The format concept separates interchange from internal serialization; JDBC's serialize() contract is not the SQL STAsBinary() contract.

LongitudeOne integration and support​

Every row concerns Doctrine Spatial 6.0.0, SQL Server adapter. Source evidence identifies the generated SQL and model scope; live server versions, every DQL function and dimensions beyond the PHP model are not certified by this record.

FeatureImplementation scopeStatusLimitationsImplementation decisionExtensionsEvidence
XY geometry persistenceDoctrine Spatial 6.0.0, SQL ServerSupportedPHP Point, LineString, Polygon and their three multi-types; not every native instance type.Declare GEOMETRY, write with geometry::STGeomFromText, read through .STAsBinary().None documented.SqlServer adapter, PHP types
Generic geography mappingDoctrine Spatial 6.0.0, SQL Server, GeographyTypePartially supportedOnly the generic mapping selects this SQL path; no FullGlobe PHP model.Declare GEOGRAPHY; use geography::STGeomFromText with SRID 4326.None documented.Adapter, Generic mapping
Geography subtype mappings to native geographyDoctrine Spatial 6.0.0, SQL Server, geography PointType, LineStringType, PolygonTypeUnsupportedOrdinary subtype persistence selects planar storage, despite the geography PHP classes.Declare GEOMETRY; use geometry::STGeomFromText with SRID 0 because the derived SQL type is Point, LineString or Polygon.None documented.Adapter, SQL type derivation, Subtype mappings
Arbitrary object SRID in ordinary persistenceDoctrine Spatial 6.0.0, SQL ServerUnsupportedThe object's SRID is not forwarded by ordinary persistence; a supplied SRID declaration is not enforced.Use SRID 4326 only for generic GeographyType; geometry and geography subtype mappings use SRID 0.None documented.Adapter
Function/property SQL adaptationDoctrine Spatial 6.0.0, SQL ServerSupportedEach DQL function still has its own accepted-platform list.Adapt static constructors, instance methods and properties; translate STPerimeter to STLength.None documented.Adapter
XYZ, XYM, XYZM, curved types, GeometryCollection and FullGlobe PHP valuesDoctrine Spatial 6.0.0, SQL ServerUnsupportedPoint has only X/Y; additional native type classes are absent.Keep released PHP type inventory.None documented.PHP types, Point
Complete EMPTY and Z/M interchange round tripsDoctrine Spatial 6.0.0, SQL ServerNot assessedDo not infer preservation from a SQL method name or native storage support.No new compatibility behavior defined.None documented.Adapter, PHP types

The distinction follows the released SQL type derivation: getSQLType() removes Type from the concrete class name. The geography subclasses do not override it, so their result is Point, LineString or Polygon, rather than Geography. The SQL Server adapter checks that result when choosing declarations and constructors; PHP geography family membership alone does not select native geography storage. This record describes the existing limitation without changing the adapter.

DBMS overview, geometry families, dimensions, CRS/SRID, formats and Doctrine Spatial 6.x usage.