Export (0) Print
Expand All
Expand Minimize

SUSER_ID (Transact-SQL)

Returns the login identification number of the user.

NoteNote

SUSER_ID always returned NULL when used in SQL Server 2000. Starting with SQL Server 2005, SUSER_ID returns the value listed as principal_id in the sys.server_principals catalog view.

Topic link iconTransact-SQL Syntax Conventions


SUSER_ID ( [ 'login' ] ) 

'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 SQL Server login or Windows user or group that has permission to connect to an instance of SQL Server. If login is not specified, the login identification number for the current user is returned.

SUSER_ID returns an identification number only for logins that have been explicitly provisioned inside SQL Server. This ID is used within SQL Server 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.

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

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

SELECT SUSER_ID('sa')
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft