get username script is running under

  • Hi all,

    Does anyone know of a command or function that returns the username that runs it?

    I'm trying to debug a backup script. It can't delete old databases as it gets an "Access is denied" message when trying to list them. I've checked permissions on the directory and both I and the SqlServerAgent have full permissions, and I've run the script under both accounts (from the Agent) and it still gets that error. It would be useful to confirm which account is running the script.

    Any input is much appreciated.

    Iain

  • Can't you use suser_sname() system function ?

  • maybe this is what you are looking for:

    select user_name() as , suser_name() as [login name]

    hth

    Piotr

    ...and your only reply is slàinte mhath

  • thanks guys, that was exactly what I looking for.

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

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