EXECUTE AS

Execute a stored procedure or function.

Syntax
      EXEC[UTE] AS CALLER [;]

      EXEC[UTE] AS USER  = 'name'
          [WITH {NO REVERT | COOKIE INTO @varbinary_variable} ]  [;]

      EXEC[UTE] AS LOGIN  = 'name'
          [WITH {NO REVERT | COOKIE INTO @varbinary_variable} ]  [;]

Key:
    LOGIN      Impersonate a login.
    USER       Impersonate a user in the current database.
	 name       A valid sysadmin user/login name.  (not a built-in account)
    NO REVERT  The context switch cannot be reverted back

Example

EXECUTE AS USER = 'scott';

“The deepest and most lifelike emotion has been expressed, and that's the reason they have taken so long to execute” ~ Rembrandt

Related:

EXECUTE
REVERT
Equivalent Oracle command: ALTER SESSION SET CURRENT_SCHEMA = schema


© Copyright SS64.com 1999-2014
Some rights reserved