SQL Flow Field Guide

Compound

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

read-modify-write (+=, -=, *=, /=, %=, &=, ^=, |=)

What changes

Input
current value of the target and an expression
Output or change
the same variable or column
Return type
Returns the data type of the argument with the higher precedence. For more information, see Data type precedence.

Syntax at a glance

expression <operator> expression

Work example

A local variable needs a compact compound assignment in a small procedural calculation.

Use one initialized scalar and compare the compound form with its expanded assignment. Avoid row-by-row variable tricks in a query.

Check your work Compound. The scalar has the same value as the expanded expression and is assigned once.

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