Discover our Clipsal Smart Home packages as seen on the Block

in location

OR

I'm looking for

  • Wholesalers
    • Uncheck All Check All
  • EXPERTISE
    • Expand
    • Expand
    • Expand
    • Uncheck All Check All
  • Switchboard Manufacturers
    • Uncheck All Check All
OR

The best way to see what Clipsal electric products can do for your home is seeing them in action at a Clipsal Display Centre.

Product stock may vary according to location. If you're after a specific product range, please check with your chosen location before visiting.

10 Results
    Load More Load Complete
    Change Location

    How to execute SQL commands as a different Login

    Issue
    How to impersonate a user or login.

    Product Line
    Power Monitoring Expert (PME)
    SQL Server

    Environment
    SQL Server Management Studio (SSMS)

    Cause
    By default, a session starts when a user logs in and ends when the user logs off. All operations during a session are subject to permission checks against that user. When an EXECUTE AS statement is run, the execution context of the session is switched to the specified login or user name. After the context switch, permissions are checked against the login and user security tokens for that account instead of the person calling the EXECUTE AS statement. In essence, the user or login account is impersonated for the duration of the session or module execution.

    Resolution
    The syntax is:
    EXECUTE AS { LOGIN | USER } = '';
    note: The context to be impersonated can be either a 'LOGIN' or a 'USER', and 'name' is a valid login or user.

    The change in execution context remains in effect until one of the following occurs:
    - Another EXECUTE AS statement is run.
    - The session is dropped.
    - A REVERT statement is issued.

    In the example below, it is determined if two different logins have 'sysadmin' server role or not. The login is changed with an 'EXECUTE AS statement.

    EXECUTE AS login = 'ION'
    IF IS_SRVROLEMEMBER ('sysadmin') = 1  
       print 'Current user''s login is a member of the sysadmin role'  
    ELSE IF IS_SRVROLEMEMBER ('sysadmin') = 0  
       print 'Current user''s login is NOT a member of the sysadmin role'  
    REVERT;

    EXECUTE AS login = 'REPORT'
    IF IS_SRVROLEMEMBER ('sysadmin') = 1  
       print 'Current user''s login is a member of the sysadmin role'  
    ELSE IF IS_SRVROLEMEMBER ('sysadmin') = 0  
       print 'Current user''s login is NOT a member of the sysadmin role'  
    REVERT;


              
     

    Didn’t find what you were looking for?

    Try Searching Again View Our Categories

    Need further assistance?

    Our Customer Care department provides total customer service solutions for our residential, industrial and commercial applications.

    Get Assistance