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

Examples

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 commands

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


 
Copyright © 1999-2024 SS64.com
Some rights reserved