This week i had a developer creating a process (job) where a database user was to have authority to query remote machines. To debug the process the developer needed to assume the role of the user running in the application. In the past i used the “Execute As Login“. This had problems this time.
First, it is very useful in such situations to know what “user” is in ‘control’. Thus, the ‘select user_name()‘ variations. For information on the choice of “Login or User” see execute as. Finally, don’t forget to “revert”!
In short, the solution is posted below: