SQL Flow Field Guide

CONTEXT_INFO

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

reads session state

What changes

Input
session CONTEXT_INFO bytes
Output or change
varbinary(128)
Return type
The context_info value. If context_info was not set: SQL Server returns NULL. SQL Database returns a unique session-specific GUID.

Syntax at a glance

CONTEXT_INFO()

Work example

Read the legacy session context binary value set by an application.

Read state in the intended scope and immediately after the statement it describes. Treat host values as untrusted.

Check your work Keep payload format and size explicit and prefer SESSION_CONTEXT for new key-value use.

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