Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SUSER_NAME (Transact-SQL)

Returns the login identification name of the user.

Topic link icon Transact-SQL Syntax Conventions


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. If contains the word NULL, will return NULL.

nvarchar(128)

In SQL Server version 7.0, the security identification number (SID) replaced the server user identification number (SUID).

SUSER_NAME returns a login name only for a login that has an entry in the syslogins system table.

SUSER_NAME can be used in a select list, in a WHERE clause, and anywhere an expression is allowed, and must always be followed by parentheses, even if no parameter is specified.

The following example returns the login identification name of the user with a login identification number of 1.

SELECT SUSER_NAME(1)
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.