geometry.STX
spatial method STX (instance.STX(...))
What changes
- Input
- spatial instance (and arguments)
- Output or change
- SQL Server type: float
- Return type
- SQL Server type: float CLR type: SqlDouble
Syntax at a glance
.STX
Work example
Use geometry.STX to read the X coordinate of a geometry point.
Confirm a point instance and document coordinate reference and units. Keep the geometry type and SRID in the review.
Check your work STX returns 3, the first planar coordinate. It is not necessarily longitude.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
-- Planar geometry. SRID 0 coordinates here are synthetic units, not metres.
DECLARE @shape geometry;
SET @shape = geometry::STGeomFromText(N'POINT(3 4)', 0);
SELECT @shape.STX AS x_coordinate,
@shape.STSrid AS source_srid,
@shape.STIsValid() AS source_is_valid;
Open Microsoft Learn for full syntax, permissions, and details for your version.