Skip to content

Latest commit

 

History

History
77 lines (60 loc) · 3.45 KB

File metadata and controls

77 lines (60 loc) · 3.45 KB

title: "SUSER_ID (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "03/14/2017" ms.prod: sql ms.prod_service: "sql-database" ms.component: "t-sql|functions" ms.reviewer: "" ms.suite: "sql" ms.technology: t-sql ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords:

  • "SUSER_ID_TSQL"
  • "SUSER_ID" dev_langs:
  • "TSQL" helpviewer_keywords:
  • "users [SQL Server], IDs"
  • "logins [SQL Server], IDs"
  • "SUSER_ID function"
  • "IDs [SQL Server], logins"
  • "identification numbers [SQL Server], logins"
  • "user IDs [SQL Server]" ms.assetid: 348911ab-b0b6-4867-aee7-e6f42e053a4a caps.latest.revision: 22 author: edmacauley ms.author: edmaca manager: craigg monikerRange: "= azuresqldb-mi-current || >= sql-server-2016 || = sqlallproducts-allversions"

SUSER_ID (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2008-asdbmi-xxxx-xxx-md]

Returns the login identification number of the user.

[!INCLUDEssMIlimitation]

Note

Starting with [!INCLUDEssVersion2005], SUSER_ID returns the value listed as principal_id in the sys.server_principals catalog view.

Topic link icon Transact-SQL Syntax Conventions

Syntax

  
SUSER_ID ( [ 'login' ] )   

Arguments

' login '
Is the login name of the user. login is nchar. If login is specified as char, login is implicitly converted to nchar. login can be any [!INCLUDEssNoVersion] login or Windows user or group that has permission to connect to an instance of [!INCLUDEssNoVersion]. If login is not specified, the login identification number for the current user is returned. If the parameter contains the word NULL will return NULL.

Return Types

int

Remarks

SUSER_ID returns an identification number only for logins that have been explicitly provisioned inside [!INCLUDEssNoVersion]. This ID is used within [!INCLUDEssNoVersion] to track ownership and permissions. This ID is not equivalent to the SID of the login that is returned by SUSER_SID. If login is a SQL Server login, the SID maps to a GUID. If login is a Windows login or Windows group, the SID maps to a Windows security identifier.

SUSER_SID returns a SUID only for a login that has an entry in the syslogins system table.

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

Examples

The following example returns the login identification number for the sa login.

SELECT SUSER_ID('sa');  

See Also

sys.server_principals (Transact-SQL)
SUSER_SID (Transact-SQL)
System Functions (Transact-SQL)