Posted on

various security functions

–execute as login = ‘sa’;
–execute as user = ‘guest’;

SELECT @@version
     –current context / execute as
     , user “user” –same as user_name()
     , user_name() “user_name” 
     , current_user “current_user”  
     , session_user “session_user” 

     –current login unless execute as
     , system_user “system_user” 
     , suser_name() “suser_name”  

     –original context
     , ORIGINAL_LOGIN() “original_login” 

GO