When there are nested impersonations (as in
exec as user = 'user1'; exec as user = 'user2'; exec as user = 'user1';), is there a way to revert all of them without having to use the
revert command multiple times (e.g.
Or at least, if one must use
revert repeatedly, is there a way to check if there is an active impersonation so one could loop the command as many times as needed (e.g.
while @@IMPERSONATION_COUNT > 0 revert;)?