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
USER
Work example
Read the current database user name in a query or audit result.
Test under the intended execution context. Use GRANT and DENY rather than returned identity text.
Check your work Execution context can change this value, so use permission checks for access control.
Open Microsoft Learn for full syntax, permissions, and details for your version.