Reputation: 6612
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
Upvotes: 3
Views: 3138
Reputation: 63415
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
Upvotes: 1