Need Help

  • Hi,

    I have a scenario..where an application user can login to the app and can run some workflows/processes. Some processes are executed as a specific user in the application. In this case the below SQL executes as a Test_Admin login.

    EXECUTE As Login = 'Test_Admin'

    SELECT Col's

    FROM TABLE...

    So, when i look at the Activity monitor/sp_who2/sys.sysprocesses, the above query runs as Test_Admin login.

    But is there anyway to find out the user who logged in to the application and executed the above Query..

    I would like o find out the application user while executing the query.

    I tried querying syslogins and sysprocesses, but I only get Test_Admin info.

    Please help!

    Thanks.

  • Check out this DMV in Books Online: sys.dm_exec_sessions

  • jack_kiran (3/6/2012)


    I would like o find out the application user while executing the query.

    Lynn's suggestion is fine if you want to look at it externally. If you want to know within the query, do a SELECT ORIGINAL_LOGIN() within the query.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply