SQL Flow Field Guide

Scalar subquery ( SELECT ... )

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

scalar subquery used as a value

What changes

Input
the inner query's sources, plus outer columns when correlated
Output or change
one value per outer row (NULL when no row; error 512 when more than one row)

Syntax at a glance

( SELECT single_column_expression FROM ... )

Work example

One value from a related query is needed in a SELECT list or predicate.

Run the sample and then make the inner query return zero rows and two rows. Keep the scalar result limited to one value.

Check your work Scalar subquery ( SELECT ... ). The subquery returns one value, NULL for no rows, and an error if it returns multiple rows.

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