O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Explicit Context Switching

With explicit context switching, you can use the EXECUTE AS statement to change the user or login used to check permissions. This is similar to the SET USER statement available in prior versions. It is extremely useful for administrators who are testing the permissions they have set for users or logins. The following example demonstrates the use of the explicit EXECUTE AS statement:

--Assume that you are connected as an administrator (DBO)--and want to prevent members of the Public role from--selecting from the Sales.Customer tableDENY SELECT ON sales.customer TO Public--We can check that user Laura cannot select from the-- Sales.Customer table using the EXECUTE AS statementEXECUTE AS USER ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required