Is there a way for SP to know who called it?

  • Hi everyone

    I am writing an SP where there is logic inside the SP that depends how the SP was called.  For example,

    Start of SP

    ....code....

    If SSIS called SP then do A else do B

    .... code ....

    End of SP

    Is there a way for SP to know who asked it to run?  In my case, the choice would be either SSIS ran the SP or I manually ran it.

    Thank you

  • It already "knows"... That's what SYSTEM_USER returns. For example...

    SELECT SYSTEM_USER AS WindowsAccount, be.*
    FROM Bakery.dbo.BakeEvents be;

    I know, looks really stupid, but the first column is the user running the query or the account it's being run under.

    Maybe you want to dump it into a conditional split sort of thing where if it's "User A", do one thing, and if it's "User B" do something else.

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

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