SQL Flow Field Guide

REVERT

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

ends EXECUTE AS

What changes

Input
none
Output or change
session security context

Syntax at a glance

REVERT [ WITH COOKIE = @varbinary_variable ]

Work example

A session must return from an impersonated context to its prior principal.

Pair each execution-context change with its expected revert point and error path.

Check your work The effective principal after revert matches the original session identity.

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