October 18, 2007 at 3:48 am
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
October 18, 2007 at 3:53 am
Can't you use suser_sname() system function ?
October 18, 2007 at 3:54 am
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
October 18, 2007 at 4:02 am
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