SYSTEM_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
SYSTEM_USER
Work example
Read the SQL Server login name for the current session.
Test under the intended execution context. Use GRANT and DENY rather than returned identity text.
Check your work Treat it as identity context for logging and not as an authorization decision.
Open Microsoft Learn for full syntax, permissions, and details for your version.