REVERT
Example
Section titled “Example”-- Assume there is an existing connection with CONTROL SERVEREXECUTE AS USER = 'CompanyUser01';SELECT SUSER_NAME();REVERT;SELECT SUSER_NAME();Output
Section titled “Output”CompanyUser01sa (or a different login with CONTROL SERVER)Explanation
Section titled “Explanation”The EXECUTE AS USER statement is used to change the execution context to the specific user ‘CompanyUser01’. The SUSER_NAME() function is then used to display the name of the user currently being utilized. Following this, the REVERT command is used to revert the context back to the prior user, and finally SUSER_NAME() function is used once more to confirm that the context has been reverted.