SQL Flow Field Guide

exist() Method

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

XQuery existence test

What changes

Input
xml instance and XQuery
Output or change
bit

Syntax at a glance

exist (XQuery)

Work example

Filter rows by whether an XML path contains a matching node.

Use exist in the predicate and include a specific node condition rather than extracting text first.

Check your work exist returns 1 or 0 for a matching sequence and can return null for a null XML instance.

Practice SQL

Open in SQL Flow
DECLARE @doc xml = N'<Order><Item quantity="2" /></Order>'; SELECT @doc.exist('/Order/Item[@quantity > 1]') AS has_large_item;

Open Microsoft Learn for full syntax, permissions, and details for your version.