DBA > Job Interview Questions > Microsoft SQL Server FAQs

What will occur with the following code in SQL S

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

What will occur with the following code in SQL Server 2005 if executed by Alice?

What will occur with the following code in SQL Server 2005 if executed by Alice?
execute as user = 'Bob' with no revert
select user_name()
go
revert
select user_name()
go


Answer
You will receive as results:

bob
An error

Explanation
The NO REVERT option with EXECUTE AS prevents the return of execution context to the previous value. If you run the REVERT statement, you will recieve the following error:

(Continued on next question...)

Other Job Interview Questions