SESSION_USER
security context lookup
What changes
- Input
- security context (login, user, roles, permissions)
- Output or change
- name, id or boolean
- Return type
- nvarchar(128)
Syntax at a glance
SESSION_USER
Work example
Read the database user associated with the current session.
Test under the intended execution context. Use GRANT and DENY rather than returned identity text.
Check your work Execution context can affect identity functions, so compare names only for diagnostics.
Open Microsoft Learn for full syntax, permissions, and details for your version.