SQL Flow Field Guide

OUTPUT clause

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

captures each affected row's before/after image

What changes

Input
inserted and deleted pseudo-tables of the DML statement; FROM tables for UPDATE/DELETE; $action for MERGE
Output or change
client result set, or a table/table variable via OUTPUT INTO

Syntax at a glance

<OUTPUT_CLAUSE> ::= { [ OUTPUT <dml_select_list> INTO { @table_variable | output_table } [ ( column_list ) ] ] [ OUTPUT <dml_select_list> ] }

Work example

A change review needs the before or after row image supplied by OUTPUT clause.

Use a table variable when practicing DML output. Select only required columns and do not assume output row order.

Check your work OUTPUT clause. The OUTPUT clause values match the affected rows and any captured rows go to the intended result or table variable.

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