Blog Pages

REVERT

REVERTSwitches the execution context back to the caller of the last EXECUTE AS statement.

SELECT SUSER_NAME(), USER_NAME(); -- sa, dbo
EXECUTE AS USER = 'myUser';
SELECT SUSER_NAME(), USER_NAME(); -- myUser, myUser
REVERT;
SELECT SUSER_NAME(), USER_NAME(); -- sa, dbo

No comments:

Post a Comment