SQL Flow Field Guide

ORIGINAL_LOGIN

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

security context lookup

What changes

Input
security context (login, user, roles, permissions)
Output or change
name, id or boolean
Return type
sysname

Syntax at a glance

ORIGINAL_LOGIN( )

Work example

Read the login that opened a session before execution-context changes.

Test under the intended execution context. Use GRANT and DENY rather than returned identity text.

Check your work Compare with SUSER_SNAME only for diagnostics and never expose the result as a secret.

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