geography.InstanceOf
spatial predicate InstanceOf
What changes
- Input
- one or two spatial instances
- Output or change
- bit
- Return type
- SQL Server return type: bit CLR return type: SqlBoolean
Syntax at a glance
.InstanceOf ( 'geography_type')
Work example
Use geography.InstanceOf to check an instance subtype before a subtype-specific operation.
Handle collections separately from simple points, lines, and polygons. Keep the geography type and SRID in the review.
Check your work Both outputs are 1 because Point is the instance type and Geometry is its ancestor.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
SELECT p.shape.InstanceOf('POINT') AS is_point, p.shape.InstanceOf('GEOMETRY') AS is_geometry FROM (VALUES (geography::Point(47.651, -122.349, 4326))) AS p(shape);
Open Microsoft Learn for full syntax, permissions, and details for your version.