Which user is running the SP

  • I need to get the users loginame, who is running the SP from within the SP how you do you do that

    ie something like

    if @@user = 'user'

    print @@user

    Many thanks

  • I only have access to version 2005 and 2008, so I don't know if the following code will work in the version you are using:

    SELECT nt_username

    FROM master.dbo.sysProcesses s

    WHERE s.spid = @@SPID

    BrainDonor

  • Not sure if the query provided is the best way of doing it, but i can confirm that it works in sql 2000

    --------------------------------------------------------------------------------------
    [highlight]Recommended Articles on How to help us help you and[/highlight]
    [highlight]solve commonly asked questions[/highlight]

    Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden[/url]
    Managing Transaction Logs by Gail Shaw[/url]
    How to post Performance problems by Gail Shaw[/url]
    Help, my database is corrupt. Now what? by Gail Shaw[/url]

  • SELECT SYSTEM_USER

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

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