geometry.STGeometryType
spatial method STGeometryType (instance.STGeometryType(...))
What changes
- Input
- spatial instance (and arguments)
- Output or change
- nvarchar(4000)
- Return type
- SQL Server return type: nvarchar(4000) CLR return type: SqlString
Syntax at a glance
.STGeometryType ( )
Work example
Use geometry.STGeometryType to read the OGC instance type name.
Use it for diagnostics and route supported shapes explicitly. Keep the geometry type and SRID in the review.
Check your work The type name is GeometryCollection. It does not report SRID or coordinate units.
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'GEOMETRYCOLLECTION(POINT(1 1), LINESTRING(0 0, 3 4))', 0);
SELECT @shape.STGeometryType() AS ogc_type_name,
@shape.STSrid AS source_srid,
@shape.STIsValid() AS source_is_valid;
Open Microsoft Learn for full syntax, permissions, and details for your version.