| title | SUSER_NAME (Transact-SQL) | Microsoft Docs | |||||||
|---|---|---|---|---|---|---|---|---|
| ms.custom | ||||||||
| ms.date | 03/14/2017 | |||||||
| ms.prod | sql | |||||||
| ms.prod_service | sql-data-warehouse, sql-database | |||||||
| ms.reviewer | ||||||||
| ms.technology | t-sql | |||||||
| ms.topic | language-reference | |||||||
| f1_keywords |
|
|||||||
| dev_langs |
|
|||||||
| helpviewer_keywords |
|
|||||||
| ms.assetid | ae598d9f-9baa-49b8-b1c1-042854206de4 | |||||||
| author | VanMSFT | |||||||
| ms.author | vanto | |||||||
| monikerRange | =azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current |
[!INCLUDEtsql-appliesto-ss2008-xxxx-asdw-xxx-md]
Returns the login identification name of the user.
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 [!INCLUDEssNoVersion] login or [!INCLUDEmsCoName] Windows user or group that has permission to connect to an instance of [!INCLUDEssNoVersion]. When server_user_id isn't specified, the login identification name for the current user is returned. If the parameter contains the word NULL, it will return NULL.
nvarchar(128)
In [!INCLUDEssNoVersion] 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. Use parentheses after SUSER_NAME, 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);