Determine what user called my stored procedure

I'm sure this has been asked, but search isn't returning the answer.

In a stored procedure, how do I get the value of the user/login that called the stored procedure (name?), assuming I don't already have server_user_id

Answers


in sql 2005

select suser_name()

http://msdn.microsoft.com/en-us/library/ms187934.aspx

SUSER_NAME ( [ server_user_id ] ) server_user_id

Is the login identification number of the user. server_user_id, which is optional, is int. server_user_id can be the login identification number of any SQL Server login or Microsoft Windows user or group that has permission to connect to an instance of SQL Server. If server_user_id is not specified, the login identification name for the current user is returned.

--

edit: just tried it with Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)

with integrated and sql security

and all these:

select suser_name()

select suser_sname()

select original_login()

select system_user

correctly return the logged user... I guess there's some problem with your configuration...

saludos

sas


Need Your Help

Parse.com Authentication error: Unable to respond to any of these challenges: {oauth=www-authenticate: OAuth realm="https://api.twitter.com"}

android authentication twitter parse-platform

After upgrading Parse Android SDK to version 1.4.1 Twitter login stopped to work. When I'm trying to login with Twitter:

I am getting error on page load in asp.net

c# asp.net

I am using asp.net when loading image it gives me error as shown below. If i do comment page load code in aspx file it works fine but not working with that.