SETUSER
legacy impersonation (deprecated)
What changes
- Input
- user name
- Output or change
- session security context
Syntax at a glance
SETUSER [ 'username' [ WITH NORESET ] ]
Work example
A legacy script uses SETUSER to change its execution identity.
Record the old behavior and plan a tested replacement with EXECUTE AS before changing the script.
Check your work The replacement restores the original context and the deprecated statement is absent from new code.
Open Microsoft Learn for full syntax, permissions, and details for your version.