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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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