geometry::STLineFromWKB
static constructor STLineFromWKB (called as type::STLineFromWKB(...))
What changes
- Input
- WKT, WKB, GML or coordinates and SRID
- Output or change
- spatial instance
- Return type
- SQL Server return type: geometry CLR return type: SqlGeometry OGC type: LineString
Syntax at a glance
STLineFromWKB ( 'WKB_linestring' , SRID )
Work example
Use geometry.STLineFromWKB to construct a line from WKB bytes.
Confirm the payload represents a line and keep its SRID beside it. Keep the geometry type and SRID in the review.
Check your work The typed constructor returns a valid LineString with the supplied SRID 0.
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 @payload varbinary(max);
SET @payload = geometry::STGeomFromText(N'LINESTRING(0 0, 3 4)', 0).STAsBinary();
DECLARE @result geometry;
SET @result = geometry::STLineFromWKB(@payload, 0);
SELECT @result.STAsText() AS line_wkt,
@result.STSrid AS result_srid,
@result.STIsValid() AS result_is_valid;
Open Microsoft Learn for full syntax, permissions, and details for your version.