SQL Server EXECUTE AS and the Ownership Chain Behind a Stored Procedure
A stored procedure can give a caller access to tables without granting direct table permissions. This is routine SQL Server design, but the effective authority can be difficult to see from a user's role membership. The module execution context and the ownership chain decide which permissions the engine evaluates.
Two related mechanisms
SQL Server can use an ownership chain when a module and the objects it references have the same owner. The caller needs permission on the module, and the engine can avoid a second permission check on an object later in the chain. This behavior supports encapsulated data access and is documented through the Database Engine permission model.
EXECUTE AS changes the execution context for a user-defined module. CALLER evaluates permissions as the person invoking the module. SELF uses the module creator or alterer, and OWNER uses the current owner of the module or its schema.…