Set the execution context of a session.
Syntax
EXEC[UTE] AS CALLER [;]
EXEC[UTE] AS USER = 'name'
[WITH {NO REVERT | COOKIE INTO @varbinary_variable} ] [;]
EXEC[UTE] AS LOGIN = 'name'
[WITH {NO REVERT | COOKIE INTO @varbinary_variable} ] [;]
Key
LOGIN Impersonate a login.
USER Impersonate a user in the current database.
name A valid sysadmin user/login name. (not a built-in account)
NO REVERT The context switch cannot be reverted back
EXECUTE AS USER = 'scott';
“The deepest and most lifelike emotion has been expressed, and that's the reason they have taken so long to execute” ~ Rembrandt
EXECUTE - Execute a stored procedure or function.
REVERT - Switch execution context back to the caller of the last EXECUTE AS statement.