Execute As Flashcards
1
Q
Why use EXECUTE AS?
A
When you want a user to be able to run a query or stored procedure one time without having to modify the underlying security permanently
2
Q
What is the syntax to EXECUTE AS?
A
EXEC(UTE) AS USER = ‘USERNAME’
REVERT
3
Q
What if you don’t want the EXECUTE AS statement to end even with a REVERT statement?
A
EXEC AS USER = ‘USERNAME’ WITH NO REVERT
4
Q
What if you want to specifically revert the EXECUTE AS statement?
A
Use WITH COOKIE:
DECLARE @COOKIE = VARBINARY(8000)
EXEC AS USER = ‘USERNAME’ WITH COOKIE INTO @COOKIE
Then: REVERT WITH COOKIE = @COOKIE